Merge lp:~wallyworld/launchpad/new-project-sharing-policies-1040989 into lp:launchpad
- new-project-sharing-policies-1040989
- Merge into devel
Proposed by
Ian Booth
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Ian Booth | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 15879 | ||||
Proposed branch: | lp:~wallyworld/launchpad/new-project-sharing-policies-1040989 | ||||
Merge into: | lp:launchpad | ||||
Diff against target: |
472 lines (+117/-36) 14 files modified
lib/lp/bugs/browser/tests/test_bug_views.py (+8/-3) lib/lp/bugs/browser/tests/test_bugs.py (+13/-3) lib/lp/bugs/browser/tests/test_bugtarget_filebug.py (+3/-3) lib/lp/bugs/tests/test_bugs_webservice.py (+3/-3) lib/lp/code/browser/tests/test_branch.py (+10/-5) lib/lp/code/browser/tests/test_product.py (+1/-2) lib/lp/code/model/tests/test_branch.py (+5/-2) lib/lp/code/model/tests/test_branchnamespace.py (+7/-5) lib/lp/registry/model/product.py (+12/-0) lib/lp/registry/services/tests/test_sharingservice.py (+0/-1) lib/lp/registry/tests/test_product.py (+26/-1) lib/lp/registry/tests/test_product_webservice.py (+2/-2) lib/lp/scripts/tests/test_garbo.py (+6/-4) lib/lp/testing/factory.py (+21/-2) |
||||
To merge this branch: | bzr merge lp:~wallyworld/launchpad/new-project-sharing-policies-1040989 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
William Grant | code | Approve | |
Review via email: mp+121532@code.launchpad.net |
Commit message
New projects are created with sensible default sharing policies.
Description of the change
== Implementation ==
The IProductSet createProduct() API is updated to ensure projects are created with the correct default sharing policies.
Open (non-proprietary) projects get PUBLIC for bugs and branches.
Proprietary projects get PROPRIETARY for bugs and branches.
== Tests ==
Update TestProduct:
- test_open_
- test_proprietar
== Lint ==
Checking for conflicts and issues in changed files.
Linting changed files:
lib/lp/
lib/lp/
To post a comment you must log in.
Revision history for this message
William Grant (wgrant) : | # |
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/bugs/browser/tests/test_bug_views.py' |
2 | --- lib/lp/bugs/browser/tests/test_bug_views.py 2012-08-28 09:49:44 +0000 |
3 | +++ lib/lp/bugs/browser/tests/test_bug_views.py 2012-08-29 21:47:18 +0000 |
4 | @@ -23,6 +23,10 @@ |
5 | InformationType, |
6 | BugSharingPolicy, |
7 | ) |
8 | +from lp.registry.interfaces.accesspolicy import ( |
9 | + IAccessPolicyGrantSource, |
10 | + IAccessPolicySource, |
11 | + ) |
12 | from lp.registry.interfaces.person import PersonVisibility |
13 | from lp.services.webapp.interfaces import IOpenLaunchBag |
14 | from lp.services.webapp.publisher import canonical_url |
15 | @@ -403,7 +407,6 @@ |
16 | # bug will become invisible but and no visibility check is performed. |
17 | product = self.factory.makeProduct( |
18 | bug_sharing_policy=BugSharingPolicy.PUBLIC_OR_PROPRIETARY) |
19 | - self.factory.makeAccessPolicy(pillar=product) |
20 | bug = self.factory.makeBug(target=product) |
21 | self._assert_secrecy_view_ajax_render(bug, 'PROPRIETARY', False) |
22 | |
23 | @@ -414,14 +417,16 @@ |
24 | bug_owner = self.factory.makePerson() |
25 | product = self.factory.makeProduct( |
26 | bug_sharing_policy=BugSharingPolicy.PUBLIC_OR_PROPRIETARY) |
27 | - self.factory.makeCommercialSubscription(product) |
28 | bug = self.factory.makeBug(target=product, owner=bug_owner) |
29 | + userdata_policy = getUtility(IAccessPolicySource).find( |
30 | + [(product, InformationType.USERDATA)]) |
31 | + getUtility(IAccessPolicyGrantSource).revokeByPolicy(userdata_policy) |
32 | |
33 | extra = {'HTTP_X_REQUESTED_WITH': 'XMLHttpRequest'} |
34 | request = LaunchpadTestRequest( |
35 | method='POST', form={ |
36 | 'field.actions.change': 'Change', |
37 | - 'field.information_type': 'PROPRIETARY', |
38 | + 'field.information_type': 'USERDATA', |
39 | 'field.validate_change': 'on'}, |
40 | **extra) |
41 | with person_logged_in(bug_owner): |
42 | |
43 | === modified file 'lib/lp/bugs/browser/tests/test_bugs.py' |
44 | --- lib/lp/bugs/browser/tests/test_bugs.py 2012-08-22 14:23:12 +0000 |
45 | +++ lib/lp/bugs/browser/tests/test_bugs.py 2012-08-29 21:47:18 +0000 |
46 | @@ -160,7 +160,7 @@ |
47 | |
48 | def test_createBug_default_private_bugs_true(self): |
49 | # createBug() does not adapt the default kwargs when they are none. |
50 | - project = self.factory.makeProduct( |
51 | + project = self.factory.makeLegacyProduct( |
52 | licenses=[License.OTHER_PROPRIETARY]) |
53 | with person_logged_in(project.owner): |
54 | project.setPrivateBugs(True, project.owner) |
55 | @@ -170,7 +170,7 @@ |
56 | |
57 | def test_createBug_public_bug_private_bugs_true(self): |
58 | # createBug() adapts a kwarg to InformationType if one is is not None. |
59 | - project = self.factory.makeProduct( |
60 | + project = self.factory.makeLegacyProduct( |
61 | licenses=[License.OTHER_PROPRIETARY]) |
62 | with person_logged_in(project.owner): |
63 | project.setPrivateBugs(True, project.owner) |
64 | @@ -202,13 +202,23 @@ |
65 | |
66 | def test_createBug_default_private_bugs_false(self): |
67 | # createBug() does not adapt the default kwargs when they are none. |
68 | + project = self.factory.makeLegacyProduct( |
69 | + licenses=[License.OTHER_PROPRIETARY]) |
70 | + with person_logged_in(project.owner): |
71 | + project.setPrivateBugs(False, project.owner) |
72 | + bug = self.application.createBug( |
73 | + project.owner, 'title', 'description', project) |
74 | + self.assertEqual(InformationType.PUBLIC, bug.information_type) |
75 | + |
76 | + def test_createBug_proprietary_project(self): |
77 | + # crateBug() make proprietary bugs for proprietary projects. |
78 | project = self.factory.makeProduct( |
79 | licenses=[License.OTHER_PROPRIETARY]) |
80 | with person_logged_in(project.owner): |
81 | project.setPrivateBugs(False, project.owner) |
82 | bug = self.application.createBug( |
83 | project.owner, 'title', 'description', project) |
84 | - self.assertEqual(InformationType.PUBLIC, bug.information_type) |
85 | + self.assertEqual(InformationType.PROPRIETARY, bug.information_type) |
86 | |
87 | def test_createBug_private_bug_private_bugs_false(self): |
88 | # createBug() adapts a kwarg to InformationType if one is is not None. |
89 | |
90 | === modified file 'lib/lp/bugs/browser/tests/test_bugtarget_filebug.py' |
91 | --- lib/lp/bugs/browser/tests/test_bugtarget_filebug.py 2012-08-22 14:23:12 +0000 |
92 | +++ lib/lp/bugs/browser/tests/test_bugtarget_filebug.py 2012-08-29 21:47:18 +0000 |
93 | @@ -362,7 +362,7 @@ |
94 | } |
95 | if information_type: |
96 | form['field.information_type'] = information_type |
97 | - product = self.factory.makeProduct(official_malone=True) |
98 | + product = self.factory.makeLegacyProduct(official_malone=True) |
99 | if private_bugs: |
100 | removeSecurityProxy(product).private_bugs = True |
101 | if bug_sharing_policy: |
102 | @@ -490,7 +490,7 @@ |
103 | 'field.security_related': 'on' if security_related else '', |
104 | 'field.actions.submit_bug': 'Submit Bug Request', |
105 | } |
106 | - product = self.factory.makeProduct(official_malone=True) |
107 | + product = self.factory.makeLegacyProduct(official_malone=True) |
108 | if private_bugs: |
109 | removeSecurityProxy(product).private_bugs = True |
110 | if bug_sharing_policy: |
111 | @@ -657,7 +657,7 @@ |
112 | self._assert_cache_values(view, True) |
113 | |
114 | def test_product_private_bugs(self): |
115 | - project = self.factory.makeProduct( |
116 | + project = self.factory.makeLegacyProduct( |
117 | official_malone=True, private_bugs=True) |
118 | user = self.factory.makePerson() |
119 | login_person(user) |
120 | |
121 | === modified file 'lib/lp/bugs/tests/test_bugs_webservice.py' |
122 | --- lib/lp/bugs/tests/test_bugs_webservice.py 2012-08-22 14:23:12 +0000 |
123 | +++ lib/lp/bugs/tests/test_bugs_webservice.py 2012-08-29 21:47:18 +0000 |
124 | @@ -380,7 +380,7 @@ |
125 | # Verify the path through user submission, to MaloneApplication to |
126 | # BugSet, and back to the user creates a private bug according |
127 | # to the project's bugs are private by default rule. |
128 | - project = self.factory.makeProduct( |
129 | + project = self.factory.makeLegacyProduct( |
130 | licenses=[License.OTHER_PROPRIETARY]) |
131 | with person_logged_in(project.owner): |
132 | project.setPrivateBugs(True, project.owner) |
133 | @@ -392,9 +392,9 @@ |
134 | |
135 | def test_explicit_private_private_bugs_true(self): |
136 | # Verify the path through user submission, to MaloneApplication to |
137 | - # BugSet, and back to the user creates a private bug beause the |
138 | + # BugSet, and back to the user creates a private bug because the |
139 | # user commands it. |
140 | - project = self.factory.makeProduct( |
141 | + project = self.factory.makeLegacyProduct( |
142 | licenses=[License.OTHER_PROPRIETARY]) |
143 | with person_logged_in(project.owner): |
144 | project.setPrivateBugs(True, project.owner) |
145 | |
146 | === modified file 'lib/lp/code/browser/tests/test_branch.py' |
147 | --- lib/lp/code/browser/tests/test_branch.py 2012-08-29 04:48:13 +0000 |
148 | +++ lib/lp/code/browser/tests/test_branch.py 2012-08-29 21:47:18 +0000 |
149 | @@ -919,7 +919,7 @@ |
150 | def test_forbidden_owner_is_error(self): |
151 | # An error is displayed if a branch's owner is changed to |
152 | # a value forbidden by the visibility policy. |
153 | - product = self.factory.makeProduct(displayname='Some Product') |
154 | + product = self.factory.makeLegacyProduct(displayname='Some Product') |
155 | person = self.factory.makePerson() |
156 | branch = self.factory.makeBranch(product=product, owner=person) |
157 | self.factory.makeTeam( |
158 | @@ -944,7 +944,8 @@ |
159 | # A branch's owner can be changed to a private team permitted by the |
160 | # visibility policy. |
161 | person = self.factory.makePerson() |
162 | - branch = self.factory.makeProductBranch(owner=person) |
163 | + product = self.factory.makeLegacyProduct() |
164 | + branch = self.factory.makeProductBranch(product=product, owner=person) |
165 | team = self.factory.makeTeam( |
166 | owner=person, displayname="Private team", |
167 | visibility=PersonVisibility.PRIVATE) |
168 | @@ -1027,14 +1028,16 @@ |
169 | self.assertContentEqual(types, view.getInformationTypesToShow()) |
170 | |
171 | def test_public_branch(self): |
172 | - # A normal public branch on a public project can only be a public |
173 | - # information type. |
174 | + # A normal public branch on a public project can be any information |
175 | + # type except embargoed and proprietary. |
176 | # The model doesn't enforce this, so it's just a UI thing. |
177 | branch = self.factory.makeBranch( |
178 | information_type=InformationType.PUBLIC) |
179 | self.assertShownTypes( |
180 | [InformationType.PUBLIC, |
181 | - InformationType.PUBLICSECURITY], |
182 | + InformationType.PUBLICSECURITY, |
183 | + InformationType.PRIVATESECURITY, |
184 | + InformationType.USERDATA], |
185 | branch) |
186 | |
187 | def test_branch_with_disallowed_type(self): |
188 | @@ -1048,6 +1051,8 @@ |
189 | self.assertShownTypes( |
190 | [InformationType.PUBLIC, |
191 | InformationType.PUBLICSECURITY, |
192 | + InformationType.PRIVATESECURITY, |
193 | + InformationType.USERDATA, |
194 | InformationType.PROPRIETARY], |
195 | branch) |
196 | |
197 | |
198 | === modified file 'lib/lp/code/browser/tests/test_product.py' |
199 | --- lib/lp/code/browser/tests/test_product.py 2012-07-17 03:51:38 +0000 |
200 | +++ lib/lp/code/browser/tests/test_product.py 2012-08-29 21:47:18 +0000 |
201 | @@ -22,7 +22,6 @@ |
202 | from lp.code.interfaces.revision import IRevisionSet |
203 | from lp.code.publisher import CodeLayer |
204 | from lp.registry.enums import InformationType |
205 | -from lp.services.features.testing import FeatureFixture |
206 | from lp.services.webapp import canonical_url |
207 | from lp.testing import ( |
208 | ANONYMOUS, |
209 | @@ -355,7 +354,7 @@ |
210 | def test_is_private(self): |
211 | team_owner = self.factory.makePerson() |
212 | team = self.factory.makeTeam(team_owner) |
213 | - product = self.factory.makeProduct(owner=team_owner) |
214 | + product = self.factory.makeLegacyProduct(owner=team_owner) |
215 | branch = self.factory.makeProductBranch(product=product) |
216 | login_person(product.owner) |
217 | product.development_focus.branch = branch |
218 | |
219 | === modified file 'lib/lp/code/model/tests/test_branch.py' |
220 | --- lib/lp/code/model/tests/test_branch.py 2012-08-22 14:23:12 +0000 |
221 | +++ lib/lp/code/model/tests/test_branch.py 2012-08-29 21:47:18 +0000 |
222 | @@ -2481,7 +2481,8 @@ |
223 | def test_public_to_private_not_allowed(self): |
224 | # If there are no privacy policies allowing private branches, then |
225 | # BranchCannotChangeInformationType is rasied. |
226 | - branch = self.factory.makeProductBranch() |
227 | + product = self.factory.makeLegacyProduct() |
228 | + branch = self.factory.makeBranch(product=product) |
229 | self.assertRaises( |
230 | BranchCannotChangeInformationType, |
231 | branch.setPrivate, |
232 | @@ -2523,7 +2524,9 @@ |
233 | # If the namespace policy does not allow public branches, attempting |
234 | # to change the branch to be public raises |
235 | # BranchCannotChangeInformationType. |
236 | - branch = self.factory.makeProductBranch( |
237 | + product = self.factory.makeLegacyProduct() |
238 | + branch = self.factory.makeBranch( |
239 | + product=product, |
240 | information_type=InformationType.USERDATA) |
241 | branch.product.setBranchVisibilityTeamPolicy( |
242 | None, BranchVisibilityRule.FORBIDDEN) |
243 | |
244 | === modified file 'lib/lp/code/model/tests/test_branchnamespace.py' |
245 | --- lib/lp/code/model/tests/test_branchnamespace.py 2012-08-24 05:09:51 +0000 |
246 | +++ lib/lp/code/model/tests/test_branchnamespace.py 2012-08-29 21:47:18 +0000 |
247 | @@ -385,7 +385,7 @@ |
248 | # and the namespace owner is in that team, then the team is |
249 | # subscribed. |
250 | person = self.factory.makePerson() |
251 | - product = self.factory.makeProduct() |
252 | + product = self.factory.makeLegacyProduct() |
253 | namespace = ProductNamespace(person, product) |
254 | team = self.factory.makeTeam(owner=person) |
255 | product.setBranchVisibilityTeamPolicy( |
256 | @@ -399,7 +399,7 @@ |
257 | team = self.factory.makeTeam( |
258 | membership_policy=TeamMembershipPolicy.MODERATED, |
259 | owner=person) |
260 | - product = self.factory.makeProduct() |
261 | + product = self.factory.makeLegacyProduct() |
262 | namespace = ProductNamespace(team, product) |
263 | product.setBranchVisibilityTeamPolicy( |
264 | team, BranchVisibilityRule.PRIVATE) |
265 | @@ -436,7 +436,7 @@ |
266 | # those rules is private, then the team that has the private rule is |
267 | # the subscriber. |
268 | person = self.factory.makePerson() |
269 | - product = self.factory.makeProduct() |
270 | + product = self.factory.makeLegacyProduct() |
271 | namespace = ProductNamespace(person, product) |
272 | product.setBranchVisibilityTeamPolicy( |
273 | self.factory.makeTeam(owner=person), BranchVisibilityRule.PUBLIC) |
274 | @@ -985,7 +985,7 @@ |
275 | BaseCanCreateBranchesMixin): |
276 | |
277 | def _getNamespace(self, owner): |
278 | - product = self.factory.makeProduct() |
279 | + product = self.factory.makeLegacyProduct() |
280 | return ProductNamespace(owner, product) |
281 | |
282 | def setUp(self): |
283 | @@ -1097,7 +1097,8 @@ |
284 | |
285 | def setUp(self): |
286 | TestCaseWithFactory.setUp(self) |
287 | - self.product = self.factory.makeProduct() |
288 | + self.product = self.factory.makeLegacyProduct() |
289 | + removeSecurityProxy(self.product).branch_sharing_policy = None |
290 | |
291 | def _getNamespace(self, owner): |
292 | return ProductNamespace(owner, self.product) |
293 | @@ -1299,6 +1300,7 @@ |
294 | 'admin@canonical.com') |
295 | # Our test product. |
296 | self.product = self.factory.makeProduct() |
297 | + removeSecurityProxy(self.product).branch_sharing_policy = None |
298 | # Create some test people. |
299 | self.albert = self.factory.makePerson( |
300 | name='albert', displayname='Albert Tester') |
301 | |
302 | === modified file 'lib/lp/registry/model/product.py' |
303 | --- lib/lp/registry/model/product.py 2012-08-23 02:52:31 +0000 |
304 | +++ lib/lp/registry/model/product.py 2012-08-29 21:47:18 +0000 |
305 | @@ -1552,8 +1552,20 @@ |
306 | project_reviewed=project_reviewed, |
307 | icon=icon, logo=logo, mugshot=mugshot, license_info=license_info) |
308 | |
309 | + # Set up the sharing policies and product licence. |
310 | + bug_sharing_policy_to_use = BugSharingPolicy.PUBLIC |
311 | + branch_sharing_policy_to_use = BranchSharingPolicy.PUBLIC |
312 | if len(licenses) > 0: |
313 | product._setLicenses(licenses, reset_project_reviewed=False) |
314 | + # By default, new non-proprietary projects use public bugs and |
315 | + # branches. Proprietary projects are given a complimentary 30 day |
316 | + # commercial subscription and so may use proprietary sharing |
317 | + # policies. |
318 | + if License.OTHER_PROPRIETARY in licenses: |
319 | + bug_sharing_policy_to_use = BugSharingPolicy.PROPRIETARY |
320 | + branch_sharing_policy_to_use = BranchSharingPolicy.PROPRIETARY |
321 | + product.setBugSharingPolicy(bug_sharing_policy_to_use) |
322 | + product.setBranchSharingPolicy(branch_sharing_policy_to_use) |
323 | |
324 | # Create a default trunk series and set it as the development focus |
325 | trunk = product.newSeries( |
326 | |
327 | === modified file 'lib/lp/registry/services/tests/test_sharingservice.py' |
328 | --- lib/lp/registry/services/tests/test_sharingservice.py 2012-08-28 23:25:43 +0000 |
329 | +++ lib/lp/registry/services/tests/test_sharingservice.py 2012-08-29 21:47:18 +0000 |
330 | @@ -183,7 +183,6 @@ |
331 | # if it is not in the nominally allowed policy list. |
332 | product = self.factory.makeProduct( |
333 | branch_sharing_policy=BranchSharingPolicy.EMBARGOED_OR_PROPRIETARY) |
334 | - self.factory.makeCommercialSubscription(product) |
335 | self._assert_getBranchSharingPolicies( |
336 | product, |
337 | [BranchSharingPolicy.PUBLIC, |
338 | |
339 | === modified file 'lib/lp/registry/tests/test_product.py' |
340 | --- lib/lp/registry/tests/test_product.py 2012-08-23 02:52:31 +0000 |
341 | +++ lib/lp/registry/tests/test_product.py 2012-08-29 21:47:18 +0000 |
342 | @@ -363,6 +363,31 @@ |
343 | grantees = set([grant.grantee for grant in grants]) |
344 | self.assertEqual(expected_grantess, grantees) |
345 | |
346 | + def test_open_product_creation_sharing_policies(self): |
347 | + # Creating a new open (non-proprietary) product sets the bug and branch |
348 | + # sharing polices to public. |
349 | + owner = self.factory.makePerson() |
350 | + with person_logged_in(owner): |
351 | + product = getUtility(IProductSet).createProduct( |
352 | + owner, 'carrot', 'Carrot', 'Carrot', 'testing', |
353 | + licenses=[License.MIT]) |
354 | + self.assertEqual(BugSharingPolicy.PUBLIC, product.bug_sharing_policy) |
355 | + self.assertEqual( |
356 | + BranchSharingPolicy.PUBLIC, product.branch_sharing_policy) |
357 | + |
358 | + def test_proprietary_product_creation_sharing_policies(self): |
359 | + # Creating a new proprietary product sets the bug and branch sharing |
360 | + # polices to proprietary. |
361 | + owner = self.factory.makePerson() |
362 | + with person_logged_in(owner): |
363 | + product = getUtility(IProductSet).createProduct( |
364 | + owner, 'carrot', 'Carrot', 'Carrot', 'testing', |
365 | + licenses=[License.OTHER_PROPRIETARY]) |
366 | + self.assertEqual( |
367 | + BugSharingPolicy.PROPRIETARY, product.bug_sharing_policy) |
368 | + self.assertEqual( |
369 | + BranchSharingPolicy.PROPRIETARY, product.branch_sharing_policy) |
370 | + |
371 | |
372 | class TestProductBugInformationTypes(TestCaseWithFactory): |
373 | |
374 | @@ -387,7 +412,7 @@ |
375 | def test_legacy_private_bugs(self): |
376 | # The deprecated private_bugs attribute overrides the default |
377 | # information type to USERDATA. |
378 | - product = self.factory.makeProduct(private_bugs=True) |
379 | + product = self.factory.makeLegacyProduct(private_bugs=True) |
380 | self.assertContentEqual( |
381 | FREE_INFORMATION_TYPES, product.getAllowedBugInformationTypes()) |
382 | self.assertEqual( |
383 | |
384 | === modified file 'lib/lp/registry/tests/test_product_webservice.py' |
385 | --- lib/lp/registry/tests/test_product_webservice.py 2012-08-22 13:57:25 +0000 |
386 | +++ lib/lp/registry/tests/test_product_webservice.py 2012-08-29 21:47:18 +0000 |
387 | @@ -67,7 +67,7 @@ |
388 | def test_branch_sharing_policy_non_commercial(self): |
389 | # An API attempt to set a commercial-only branch_sharing_policy |
390 | # on a non-commercial project returns Forbidden. |
391 | - product = self.factory.makeProduct() |
392 | + product = self.factory.makeLegacyProduct() |
393 | webservice = webservice_for_person( |
394 | product.owner, permission=OAuthPermission.WRITE_PRIVATE) |
395 | response = self.patch( |
396 | @@ -93,7 +93,7 @@ |
397 | def test_bug_sharing_policy_non_commercial(self): |
398 | # An API attempt to set a commercial-only bug_sharing_policy |
399 | # on a non-commercial project returns Forbidden. |
400 | - product = self.factory.makeProduct() |
401 | + product = self.factory.makeLegacyProduct() |
402 | webservice = webservice_for_person( |
403 | product.owner, permission=OAuthPermission.WRITE_PRIVATE) |
404 | response = self.patch( |
405 | |
406 | === modified file 'lib/lp/scripts/tests/test_garbo.py' |
407 | --- lib/lp/scripts/tests/test_garbo.py 2012-08-29 14:16:30 +0000 |
408 | +++ lib/lp/scripts/tests/test_garbo.py 2012-08-29 21:47:18 +0000 |
409 | @@ -1036,14 +1036,16 @@ |
410 | # set. |
411 | with dbuser('testadmin'): |
412 | non_commercial_products = [ |
413 | - self.factory.makeProduct() |
414 | + self.factory.makeLegacyProduct() |
415 | for i in range(10)] |
416 | - commercial_project = self.factory.makeProduct() |
417 | + commercial_project = self.factory.makeLegacyProduct() |
418 | self.factory.makeCommercialSubscription(commercial_project) |
419 | configured_project = self.factory.makeProduct( |
420 | bug_sharing_policy=BugSharingPolicy.PROPRIETARY) |
421 | - private_project = self.factory.makeProduct(private_bugs=True) |
422 | - project_with_bvp = self.factory.makeProduct() |
423 | + removeSecurityProxy( |
424 | + configured_project).branch_sharing_policy = None |
425 | + private_project = self.factory.makeLegacyProduct(private_bugs=True) |
426 | + project_with_bvp = self.factory.makeLegacyProduct() |
427 | project_with_bvp.setBranchVisibilityTeamPolicy( |
428 | None, BranchVisibilityRule.FORBIDDEN) |
429 | |
430 | |
431 | === modified file 'lib/lp/testing/factory.py' |
432 | --- lib/lp/testing/factory.py 2012-08-28 00:00:47 +0000 |
433 | +++ lib/lp/testing/factory.py 2012-08-29 21:47:18 +0000 |
434 | @@ -137,6 +137,8 @@ |
435 | IHWSubmissionSet, |
436 | ) |
437 | from lp.registry.enums import ( |
438 | + BranchSharingPolicy, |
439 | + BugSharingPolicy, |
440 | DistroSeriesDifferenceStatus, |
441 | DistroSeriesDifferenceType, |
442 | InformationType, |
443 | @@ -995,10 +997,27 @@ |
444 | naked_product.driver = driver |
445 | if private_bugs: |
446 | naked_product.private_bugs = private_bugs |
447 | + if ((branch_sharing_policy and |
448 | + branch_sharing_policy != BranchSharingPolicy.PUBLIC) or |
449 | + (bug_sharing_policy and |
450 | + bug_sharing_policy != BugSharingPolicy.PUBLIC)): |
451 | + self.makeCommercialSubscription(product) |
452 | if branch_sharing_policy: |
453 | - naked_product.branch_sharing_policy = branch_sharing_policy |
454 | + naked_product.setBranchSharingPolicy(branch_sharing_policy) |
455 | if bug_sharing_policy: |
456 | - naked_product.bug_sharing_policy = bug_sharing_policy |
457 | + naked_product.setBugSharingPolicy(bug_sharing_policy) |
458 | + |
459 | + return product |
460 | + |
461 | + def makeLegacyProduct(self, **kwargs): |
462 | + # Create a product which does not have any of the new bug and branch |
463 | + # sharing policies set. New products have these set to default values |
464 | + # but we need to test for existing products which have not yet been |
465 | + # migrated. |
466 | + # XXX This method can be removed when branch visibility policy dies. |
467 | + product = self.makeProduct(**kwargs) |
468 | + removeSecurityProxy(product).bug_sharing_policy = None |
469 | + removeSecurityProxy(product).branch_sharing_policy = None |
470 | return product |
471 | |
472 | def makeProductSeries(self, product=None, name=None, owner=None, |