Merge lp:~wallyworld/launchpad/bug-sharing-policy-weirdness-1055250 into lp:launchpad

Proposed by Ian Booth
Status: Merged
Approved by: Ian Booth
Approved revision: no longer in the source branch.
Merged at revision: 16007
Proposed branch: lp:~wallyworld/launchpad/bug-sharing-policy-weirdness-1055250
Merge into: lp:launchpad
Diff against target: 52 lines (+24/-0)
2 files modified
lib/lp/registry/services/sharingservice.py (+3/-0)
lib/lp/registry/services/tests/test_sharingservice.py (+21/-0)
To merge this branch: bzr merge lp:~wallyworld/launchpad/bug-sharing-policy-weirdness-1055250
Reviewer Review Type Date Requested Status
Steve Kowalik (community) code Approve
Review via email: mp+125916@code.launchpad.net

Commit message

The sharing service getBugSharingPolicy includes the pillar's current policy even if it is not nominally allowed.

Description of the change

== Implementation ==

The UI was not updating correctly because the allowed bug sharing policies fetched from the sharing service did not include the current sharing policy. The current policy was no longer allowed but still needs to be supplied to the UI if it is the current one.

Branches worked correctly. Bugs needed to be updated to match.

== Tests ==

Add some more tests to test_sharingservice. The branch functionality was not tested so I added a test for that as well as one for the new bug functionality.

== Lint ==

Linting changed files:
  lib/lp/registry/services/sharingservice.py
  lib/lp/registry/services/tests/test_sharingservice.py

To post a comment you must log in.
Revision history for this message
Steve Kowalik (stevenk) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/services/sharingservice.py'
2--- lib/lp/registry/services/sharingservice.py 2012-09-19 13:22:42 +0000
3+++ lib/lp/registry/services/sharingservice.py 2012-09-24 04:00:26 +0000
4@@ -386,6 +386,9 @@
5 BugSharingPolicy.PUBLIC_OR_PROPRIETARY,
6 BugSharingPolicy.PROPRIETARY_OR_PUBLIC,
7 BugSharingPolicy.PROPRIETARY])
8+ if (pillar.bug_sharing_policy and
9+ not pillar.bug_sharing_policy in allowed_policies):
10+ allowed_policies.append(pillar.bug_sharing_policy)
11
12 return self._makeEnumData(allowed_policies)
13
14
15=== modified file 'lib/lp/registry/services/tests/test_sharingservice.py'
16--- lib/lp/registry/services/tests/test_sharingservice.py 2012-09-19 13:22:42 +0000
17+++ lib/lp/registry/services/tests/test_sharingservice.py 2012-09-24 04:00:26 +0000
18@@ -190,6 +190,17 @@
19 BranchSharingPolicy.PROPRIETARY_OR_PUBLIC,
20 BranchSharingPolicy.PROPRIETARY])
21
22+ def test_getBranchSharingPolicies_disallowed_policy(self):
23+ # getBranchSharingPolicies includes a pillar's current policy even if
24+ # it is nominally not allowed.
25+ product = self.factory.makeProduct()
26+ self.factory.makeCommercialSubscription(product, expired=True)
27+ with person_logged_in(product.owner):
28+ product.setBranchSharingPolicy(BranchSharingPolicy.FORBIDDEN)
29+ self._assert_getBranchSharingPolicies(
30+ product,
31+ [BranchSharingPolicy.PUBLIC, BranchSharingPolicy.FORBIDDEN])
32+
33 def test_getBranchSharingPolicies_product_with_embargoed(self):
34 # The sharing policies will contain the product's sharing policy even
35 # if it is not in the nominally allowed policy list.
36@@ -276,6 +287,16 @@
37 BugSharingPolicy.PROPRIETARY_OR_PUBLIC,
38 BugSharingPolicy.PROPRIETARY])
39
40+ def test_getBugSharingPolicies_disallowed_policy(self):
41+ # getBugSharingPolicies includes a pillar's current policy even if it
42+ # is nominally not allowed.
43+ product = self.factory.makeProduct()
44+ self.factory.makeCommercialSubscription(product, expired=True)
45+ with person_logged_in(product.owner):
46+ product.setBugSharingPolicy(BugSharingPolicy.FORBIDDEN)
47+ self._assert_getBugSharingPolicies(
48+ product, [BugSharingPolicy.PUBLIC, BugSharingPolicy.FORBIDDEN])
49+
50 def test_getBugSharingPolicies_distro(self):
51 distro = self.factory.makeDistribution()
52 self._assert_getBugSharingPolicies(distro, [BugSharingPolicy.PUBLIC])