Merge lp:~wallyworld/launchpad/new-project-sharing-policies-1040989 into lp:launchpad

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
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_product_creation_sharing_policies
- test_proprietary_product_creation_sharing_policies

== Lint ==

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/registry/model/product.py
  lib/lp/registry/tests/test_product.py

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
=== modified file 'lib/lp/bugs/browser/tests/test_bug_views.py'
--- lib/lp/bugs/browser/tests/test_bug_views.py 2012-08-28 09:49:44 +0000
+++ lib/lp/bugs/browser/tests/test_bug_views.py 2012-08-29 21:47:18 +0000
@@ -23,6 +23,10 @@
23 InformationType,23 InformationType,
24 BugSharingPolicy,24 BugSharingPolicy,
25 )25 )
26from lp.registry.interfaces.accesspolicy import (
27 IAccessPolicyGrantSource,
28 IAccessPolicySource,
29 )
26from lp.registry.interfaces.person import PersonVisibility30from lp.registry.interfaces.person import PersonVisibility
27from lp.services.webapp.interfaces import IOpenLaunchBag31from lp.services.webapp.interfaces import IOpenLaunchBag
28from lp.services.webapp.publisher import canonical_url32from lp.services.webapp.publisher import canonical_url
@@ -403,7 +407,6 @@
403 # bug will become invisible but and no visibility check is performed.407 # bug will become invisible but and no visibility check is performed.
404 product = self.factory.makeProduct(408 product = self.factory.makeProduct(
405 bug_sharing_policy=BugSharingPolicy.PUBLIC_OR_PROPRIETARY)409 bug_sharing_policy=BugSharingPolicy.PUBLIC_OR_PROPRIETARY)
406 self.factory.makeAccessPolicy(pillar=product)
407 bug = self.factory.makeBug(target=product)410 bug = self.factory.makeBug(target=product)
408 self._assert_secrecy_view_ajax_render(bug, 'PROPRIETARY', False)411 self._assert_secrecy_view_ajax_render(bug, 'PROPRIETARY', False)
409412
@@ -414,14 +417,16 @@
414 bug_owner = self.factory.makePerson()417 bug_owner = self.factory.makePerson()
415 product = self.factory.makeProduct(418 product = self.factory.makeProduct(
416 bug_sharing_policy=BugSharingPolicy.PUBLIC_OR_PROPRIETARY)419 bug_sharing_policy=BugSharingPolicy.PUBLIC_OR_PROPRIETARY)
417 self.factory.makeCommercialSubscription(product)
418 bug = self.factory.makeBug(target=product, owner=bug_owner)420 bug = self.factory.makeBug(target=product, owner=bug_owner)
421 userdata_policy = getUtility(IAccessPolicySource).find(
422 [(product, InformationType.USERDATA)])
423 getUtility(IAccessPolicyGrantSource).revokeByPolicy(userdata_policy)
419424
420 extra = {'HTTP_X_REQUESTED_WITH': 'XMLHttpRequest'}425 extra = {'HTTP_X_REQUESTED_WITH': 'XMLHttpRequest'}
421 request = LaunchpadTestRequest(426 request = LaunchpadTestRequest(
422 method='POST', form={427 method='POST', form={
423 'field.actions.change': 'Change',428 'field.actions.change': 'Change',
424 'field.information_type': 'PROPRIETARY',429 'field.information_type': 'USERDATA',
425 'field.validate_change': 'on'},430 'field.validate_change': 'on'},
426 **extra)431 **extra)
427 with person_logged_in(bug_owner):432 with person_logged_in(bug_owner):
428433
=== modified file 'lib/lp/bugs/browser/tests/test_bugs.py'
--- lib/lp/bugs/browser/tests/test_bugs.py 2012-08-22 14:23:12 +0000
+++ lib/lp/bugs/browser/tests/test_bugs.py 2012-08-29 21:47:18 +0000
@@ -160,7 +160,7 @@
160160
161 def test_createBug_default_private_bugs_true(self):161 def test_createBug_default_private_bugs_true(self):
162 # createBug() does not adapt the default kwargs when they are none.162 # createBug() does not adapt the default kwargs when they are none.
163 project = self.factory.makeProduct(163 project = self.factory.makeLegacyProduct(
164 licenses=[License.OTHER_PROPRIETARY])164 licenses=[License.OTHER_PROPRIETARY])
165 with person_logged_in(project.owner):165 with person_logged_in(project.owner):
166 project.setPrivateBugs(True, project.owner)166 project.setPrivateBugs(True, project.owner)
@@ -170,7 +170,7 @@
170170
171 def test_createBug_public_bug_private_bugs_true(self):171 def test_createBug_public_bug_private_bugs_true(self):
172 # createBug() adapts a kwarg to InformationType if one is is not None.172 # createBug() adapts a kwarg to InformationType if one is is not None.
173 project = self.factory.makeProduct(173 project = self.factory.makeLegacyProduct(
174 licenses=[License.OTHER_PROPRIETARY])174 licenses=[License.OTHER_PROPRIETARY])
175 with person_logged_in(project.owner):175 with person_logged_in(project.owner):
176 project.setPrivateBugs(True, project.owner)176 project.setPrivateBugs(True, project.owner)
@@ -202,13 +202,23 @@
202202
203 def test_createBug_default_private_bugs_false(self):203 def test_createBug_default_private_bugs_false(self):
204 # createBug() does not adapt the default kwargs when they are none.204 # createBug() does not adapt the default kwargs when they are none.
205 project = self.factory.makeLegacyProduct(
206 licenses=[License.OTHER_PROPRIETARY])
207 with person_logged_in(project.owner):
208 project.setPrivateBugs(False, project.owner)
209 bug = self.application.createBug(
210 project.owner, 'title', 'description', project)
211 self.assertEqual(InformationType.PUBLIC, bug.information_type)
212
213 def test_createBug_proprietary_project(self):
214 # crateBug() make proprietary bugs for proprietary projects.
205 project = self.factory.makeProduct(215 project = self.factory.makeProduct(
206 licenses=[License.OTHER_PROPRIETARY])216 licenses=[License.OTHER_PROPRIETARY])
207 with person_logged_in(project.owner):217 with person_logged_in(project.owner):
208 project.setPrivateBugs(False, project.owner)218 project.setPrivateBugs(False, project.owner)
209 bug = self.application.createBug(219 bug = self.application.createBug(
210 project.owner, 'title', 'description', project)220 project.owner, 'title', 'description', project)
211 self.assertEqual(InformationType.PUBLIC, bug.information_type)221 self.assertEqual(InformationType.PROPRIETARY, bug.information_type)
212222
213 def test_createBug_private_bug_private_bugs_false(self):223 def test_createBug_private_bug_private_bugs_false(self):
214 # createBug() adapts a kwarg to InformationType if one is is not None.224 # createBug() adapts a kwarg to InformationType if one is is not None.
215225
=== modified file 'lib/lp/bugs/browser/tests/test_bugtarget_filebug.py'
--- lib/lp/bugs/browser/tests/test_bugtarget_filebug.py 2012-08-22 14:23:12 +0000
+++ lib/lp/bugs/browser/tests/test_bugtarget_filebug.py 2012-08-29 21:47:18 +0000
@@ -362,7 +362,7 @@
362 }362 }
363 if information_type:363 if information_type:
364 form['field.information_type'] = information_type364 form['field.information_type'] = information_type
365 product = self.factory.makeProduct(official_malone=True)365 product = self.factory.makeLegacyProduct(official_malone=True)
366 if private_bugs:366 if private_bugs:
367 removeSecurityProxy(product).private_bugs = True367 removeSecurityProxy(product).private_bugs = True
368 if bug_sharing_policy:368 if bug_sharing_policy:
@@ -490,7 +490,7 @@
490 'field.security_related': 'on' if security_related else '',490 'field.security_related': 'on' if security_related else '',
491 'field.actions.submit_bug': 'Submit Bug Request',491 'field.actions.submit_bug': 'Submit Bug Request',
492 }492 }
493 product = self.factory.makeProduct(official_malone=True)493 product = self.factory.makeLegacyProduct(official_malone=True)
494 if private_bugs:494 if private_bugs:
495 removeSecurityProxy(product).private_bugs = True495 removeSecurityProxy(product).private_bugs = True
496 if bug_sharing_policy:496 if bug_sharing_policy:
@@ -657,7 +657,7 @@
657 self._assert_cache_values(view, True)657 self._assert_cache_values(view, True)
658658
659 def test_product_private_bugs(self):659 def test_product_private_bugs(self):
660 project = self.factory.makeProduct(660 project = self.factory.makeLegacyProduct(
661 official_malone=True, private_bugs=True)661 official_malone=True, private_bugs=True)
662 user = self.factory.makePerson()662 user = self.factory.makePerson()
663 login_person(user)663 login_person(user)
664664
=== modified file 'lib/lp/bugs/tests/test_bugs_webservice.py'
--- lib/lp/bugs/tests/test_bugs_webservice.py 2012-08-22 14:23:12 +0000
+++ lib/lp/bugs/tests/test_bugs_webservice.py 2012-08-29 21:47:18 +0000
@@ -380,7 +380,7 @@
380 # Verify the path through user submission, to MaloneApplication to380 # Verify the path through user submission, to MaloneApplication to
381 # BugSet, and back to the user creates a private bug according381 # BugSet, and back to the user creates a private bug according
382 # to the project's bugs are private by default rule.382 # to the project's bugs are private by default rule.
383 project = self.factory.makeProduct(383 project = self.factory.makeLegacyProduct(
384 licenses=[License.OTHER_PROPRIETARY])384 licenses=[License.OTHER_PROPRIETARY])
385 with person_logged_in(project.owner):385 with person_logged_in(project.owner):
386 project.setPrivateBugs(True, project.owner)386 project.setPrivateBugs(True, project.owner)
@@ -392,9 +392,9 @@
392392
393 def test_explicit_private_private_bugs_true(self):393 def test_explicit_private_private_bugs_true(self):
394 # Verify the path through user submission, to MaloneApplication to394 # Verify the path through user submission, to MaloneApplication to
395 # BugSet, and back to the user creates a private bug beause the395 # BugSet, and back to the user creates a private bug because the
396 # user commands it.396 # user commands it.
397 project = self.factory.makeProduct(397 project = self.factory.makeLegacyProduct(
398 licenses=[License.OTHER_PROPRIETARY])398 licenses=[License.OTHER_PROPRIETARY])
399 with person_logged_in(project.owner):399 with person_logged_in(project.owner):
400 project.setPrivateBugs(True, project.owner)400 project.setPrivateBugs(True, project.owner)
401401
=== modified file 'lib/lp/code/browser/tests/test_branch.py'
--- lib/lp/code/browser/tests/test_branch.py 2012-08-29 04:48:13 +0000
+++ lib/lp/code/browser/tests/test_branch.py 2012-08-29 21:47:18 +0000
@@ -919,7 +919,7 @@
919 def test_forbidden_owner_is_error(self):919 def test_forbidden_owner_is_error(self):
920 # An error is displayed if a branch's owner is changed to920 # An error is displayed if a branch's owner is changed to
921 # a value forbidden by the visibility policy.921 # a value forbidden by the visibility policy.
922 product = self.factory.makeProduct(displayname='Some Product')922 product = self.factory.makeLegacyProduct(displayname='Some Product')
923 person = self.factory.makePerson()923 person = self.factory.makePerson()
924 branch = self.factory.makeBranch(product=product, owner=person)924 branch = self.factory.makeBranch(product=product, owner=person)
925 self.factory.makeTeam(925 self.factory.makeTeam(
@@ -944,7 +944,8 @@
944 # A branch's owner can be changed to a private team permitted by the944 # A branch's owner can be changed to a private team permitted by the
945 # visibility policy.945 # visibility policy.
946 person = self.factory.makePerson()946 person = self.factory.makePerson()
947 branch = self.factory.makeProductBranch(owner=person)947 product = self.factory.makeLegacyProduct()
948 branch = self.factory.makeProductBranch(product=product, owner=person)
948 team = self.factory.makeTeam(949 team = self.factory.makeTeam(
949 owner=person, displayname="Private team",950 owner=person, displayname="Private team",
950 visibility=PersonVisibility.PRIVATE)951 visibility=PersonVisibility.PRIVATE)
@@ -1027,14 +1028,16 @@
1027 self.assertContentEqual(types, view.getInformationTypesToShow())1028 self.assertContentEqual(types, view.getInformationTypesToShow())
10281029
1029 def test_public_branch(self):1030 def test_public_branch(self):
1030 # A normal public branch on a public project can only be a public1031 # A normal public branch on a public project can be any information
1031 # information type.1032 # type except embargoed and proprietary.
1032 # The model doesn't enforce this, so it's just a UI thing.1033 # The model doesn't enforce this, so it's just a UI thing.
1033 branch = self.factory.makeBranch(1034 branch = self.factory.makeBranch(
1034 information_type=InformationType.PUBLIC)1035 information_type=InformationType.PUBLIC)
1035 self.assertShownTypes(1036 self.assertShownTypes(
1036 [InformationType.PUBLIC,1037 [InformationType.PUBLIC,
1037 InformationType.PUBLICSECURITY],1038 InformationType.PUBLICSECURITY,
1039 InformationType.PRIVATESECURITY,
1040 InformationType.USERDATA],
1038 branch)1041 branch)
10391042
1040 def test_branch_with_disallowed_type(self):1043 def test_branch_with_disallowed_type(self):
@@ -1048,6 +1051,8 @@
1048 self.assertShownTypes(1051 self.assertShownTypes(
1049 [InformationType.PUBLIC,1052 [InformationType.PUBLIC,
1050 InformationType.PUBLICSECURITY,1053 InformationType.PUBLICSECURITY,
1054 InformationType.PRIVATESECURITY,
1055 InformationType.USERDATA,
1051 InformationType.PROPRIETARY],1056 InformationType.PROPRIETARY],
1052 branch)1057 branch)
10531058
10541059
=== modified file 'lib/lp/code/browser/tests/test_product.py'
--- lib/lp/code/browser/tests/test_product.py 2012-07-17 03:51:38 +0000
+++ lib/lp/code/browser/tests/test_product.py 2012-08-29 21:47:18 +0000
@@ -22,7 +22,6 @@
22from lp.code.interfaces.revision import IRevisionSet22from lp.code.interfaces.revision import IRevisionSet
23from lp.code.publisher import CodeLayer23from lp.code.publisher import CodeLayer
24from lp.registry.enums import InformationType24from lp.registry.enums import InformationType
25from lp.services.features.testing import FeatureFixture
26from lp.services.webapp import canonical_url25from lp.services.webapp import canonical_url
27from lp.testing import (26from lp.testing import (
28 ANONYMOUS,27 ANONYMOUS,
@@ -355,7 +354,7 @@
355 def test_is_private(self):354 def test_is_private(self):
356 team_owner = self.factory.makePerson()355 team_owner = self.factory.makePerson()
357 team = self.factory.makeTeam(team_owner)356 team = self.factory.makeTeam(team_owner)
358 product = self.factory.makeProduct(owner=team_owner)357 product = self.factory.makeLegacyProduct(owner=team_owner)
359 branch = self.factory.makeProductBranch(product=product)358 branch = self.factory.makeProductBranch(product=product)
360 login_person(product.owner)359 login_person(product.owner)
361 product.development_focus.branch = branch360 product.development_focus.branch = branch
362361
=== modified file 'lib/lp/code/model/tests/test_branch.py'
--- lib/lp/code/model/tests/test_branch.py 2012-08-22 14:23:12 +0000
+++ lib/lp/code/model/tests/test_branch.py 2012-08-29 21:47:18 +0000
@@ -2481,7 +2481,8 @@
2481 def test_public_to_private_not_allowed(self):2481 def test_public_to_private_not_allowed(self):
2482 # If there are no privacy policies allowing private branches, then2482 # If there are no privacy policies allowing private branches, then
2483 # BranchCannotChangeInformationType is rasied.2483 # BranchCannotChangeInformationType is rasied.
2484 branch = self.factory.makeProductBranch()2484 product = self.factory.makeLegacyProduct()
2485 branch = self.factory.makeBranch(product=product)
2485 self.assertRaises(2486 self.assertRaises(
2486 BranchCannotChangeInformationType,2487 BranchCannotChangeInformationType,
2487 branch.setPrivate,2488 branch.setPrivate,
@@ -2523,7 +2524,9 @@
2523 # If the namespace policy does not allow public branches, attempting2524 # If the namespace policy does not allow public branches, attempting
2524 # to change the branch to be public raises2525 # to change the branch to be public raises
2525 # BranchCannotChangeInformationType.2526 # BranchCannotChangeInformationType.
2526 branch = self.factory.makeProductBranch(2527 product = self.factory.makeLegacyProduct()
2528 branch = self.factory.makeBranch(
2529 product=product,
2527 information_type=InformationType.USERDATA)2530 information_type=InformationType.USERDATA)
2528 branch.product.setBranchVisibilityTeamPolicy(2531 branch.product.setBranchVisibilityTeamPolicy(
2529 None, BranchVisibilityRule.FORBIDDEN)2532 None, BranchVisibilityRule.FORBIDDEN)
25302533
=== modified file 'lib/lp/code/model/tests/test_branchnamespace.py'
--- lib/lp/code/model/tests/test_branchnamespace.py 2012-08-24 05:09:51 +0000
+++ lib/lp/code/model/tests/test_branchnamespace.py 2012-08-29 21:47:18 +0000
@@ -385,7 +385,7 @@
385 # and the namespace owner is in that team, then the team is385 # and the namespace owner is in that team, then the team is
386 # subscribed.386 # subscribed.
387 person = self.factory.makePerson()387 person = self.factory.makePerson()
388 product = self.factory.makeProduct()388 product = self.factory.makeLegacyProduct()
389 namespace = ProductNamespace(person, product)389 namespace = ProductNamespace(person, product)
390 team = self.factory.makeTeam(owner=person)390 team = self.factory.makeTeam(owner=person)
391 product.setBranchVisibilityTeamPolicy(391 product.setBranchVisibilityTeamPolicy(
@@ -399,7 +399,7 @@
399 team = self.factory.makeTeam(399 team = self.factory.makeTeam(
400 membership_policy=TeamMembershipPolicy.MODERATED,400 membership_policy=TeamMembershipPolicy.MODERATED,
401 owner=person)401 owner=person)
402 product = self.factory.makeProduct()402 product = self.factory.makeLegacyProduct()
403 namespace = ProductNamespace(team, product)403 namespace = ProductNamespace(team, product)
404 product.setBranchVisibilityTeamPolicy(404 product.setBranchVisibilityTeamPolicy(
405 team, BranchVisibilityRule.PRIVATE)405 team, BranchVisibilityRule.PRIVATE)
@@ -436,7 +436,7 @@
436 # those rules is private, then the team that has the private rule is436 # those rules is private, then the team that has the private rule is
437 # the subscriber.437 # the subscriber.
438 person = self.factory.makePerson()438 person = self.factory.makePerson()
439 product = self.factory.makeProduct()439 product = self.factory.makeLegacyProduct()
440 namespace = ProductNamespace(person, product)440 namespace = ProductNamespace(person, product)
441 product.setBranchVisibilityTeamPolicy(441 product.setBranchVisibilityTeamPolicy(
442 self.factory.makeTeam(owner=person), BranchVisibilityRule.PUBLIC)442 self.factory.makeTeam(owner=person), BranchVisibilityRule.PUBLIC)
@@ -985,7 +985,7 @@
985 BaseCanCreateBranchesMixin):985 BaseCanCreateBranchesMixin):
986986
987 def _getNamespace(self, owner):987 def _getNamespace(self, owner):
988 product = self.factory.makeProduct()988 product = self.factory.makeLegacyProduct()
989 return ProductNamespace(owner, product)989 return ProductNamespace(owner, product)
990990
991 def setUp(self):991 def setUp(self):
@@ -1097,7 +1097,8 @@
10971097
1098 def setUp(self):1098 def setUp(self):
1099 TestCaseWithFactory.setUp(self)1099 TestCaseWithFactory.setUp(self)
1100 self.product = self.factory.makeProduct()1100 self.product = self.factory.makeLegacyProduct()
1101 removeSecurityProxy(self.product).branch_sharing_policy = None
11011102
1102 def _getNamespace(self, owner):1103 def _getNamespace(self, owner):
1103 return ProductNamespace(owner, self.product)1104 return ProductNamespace(owner, self.product)
@@ -1299,6 +1300,7 @@
1299 'admin@canonical.com')1300 'admin@canonical.com')
1300 # Our test product.1301 # Our test product.
1301 self.product = self.factory.makeProduct()1302 self.product = self.factory.makeProduct()
1303 removeSecurityProxy(self.product).branch_sharing_policy = None
1302 # Create some test people.1304 # Create some test people.
1303 self.albert = self.factory.makePerson(1305 self.albert = self.factory.makePerson(
1304 name='albert', displayname='Albert Tester')1306 name='albert', displayname='Albert Tester')
13051307
=== modified file 'lib/lp/registry/model/product.py'
--- lib/lp/registry/model/product.py 2012-08-23 02:52:31 +0000
+++ lib/lp/registry/model/product.py 2012-08-29 21:47:18 +0000
@@ -1552,8 +1552,20 @@
1552 project_reviewed=project_reviewed,1552 project_reviewed=project_reviewed,
1553 icon=icon, logo=logo, mugshot=mugshot, license_info=license_info)1553 icon=icon, logo=logo, mugshot=mugshot, license_info=license_info)
15541554
1555 # Set up the sharing policies and product licence.
1556 bug_sharing_policy_to_use = BugSharingPolicy.PUBLIC
1557 branch_sharing_policy_to_use = BranchSharingPolicy.PUBLIC
1555 if len(licenses) > 0:1558 if len(licenses) > 0:
1556 product._setLicenses(licenses, reset_project_reviewed=False)1559 product._setLicenses(licenses, reset_project_reviewed=False)
1560 # By default, new non-proprietary projects use public bugs and
1561 # branches. Proprietary projects are given a complimentary 30 day
1562 # commercial subscription and so may use proprietary sharing
1563 # policies.
1564 if License.OTHER_PROPRIETARY in licenses:
1565 bug_sharing_policy_to_use = BugSharingPolicy.PROPRIETARY
1566 branch_sharing_policy_to_use = BranchSharingPolicy.PROPRIETARY
1567 product.setBugSharingPolicy(bug_sharing_policy_to_use)
1568 product.setBranchSharingPolicy(branch_sharing_policy_to_use)
15571569
1558 # Create a default trunk series and set it as the development focus1570 # Create a default trunk series and set it as the development focus
1559 trunk = product.newSeries(1571 trunk = product.newSeries(
15601572
=== modified file 'lib/lp/registry/services/tests/test_sharingservice.py'
--- lib/lp/registry/services/tests/test_sharingservice.py 2012-08-28 23:25:43 +0000
+++ lib/lp/registry/services/tests/test_sharingservice.py 2012-08-29 21:47:18 +0000
@@ -183,7 +183,6 @@
183 # if it is not in the nominally allowed policy list.183 # if it is not in the nominally allowed policy list.
184 product = self.factory.makeProduct(184 product = self.factory.makeProduct(
185 branch_sharing_policy=BranchSharingPolicy.EMBARGOED_OR_PROPRIETARY)185 branch_sharing_policy=BranchSharingPolicy.EMBARGOED_OR_PROPRIETARY)
186 self.factory.makeCommercialSubscription(product)
187 self._assert_getBranchSharingPolicies(186 self._assert_getBranchSharingPolicies(
188 product,187 product,
189 [BranchSharingPolicy.PUBLIC,188 [BranchSharingPolicy.PUBLIC,
190189
=== modified file 'lib/lp/registry/tests/test_product.py'
--- lib/lp/registry/tests/test_product.py 2012-08-23 02:52:31 +0000
+++ lib/lp/registry/tests/test_product.py 2012-08-29 21:47:18 +0000
@@ -363,6 +363,31 @@
363 grantees = set([grant.grantee for grant in grants])363 grantees = set([grant.grantee for grant in grants])
364 self.assertEqual(expected_grantess, grantees)364 self.assertEqual(expected_grantess, grantees)
365365
366 def test_open_product_creation_sharing_policies(self):
367 # Creating a new open (non-proprietary) product sets the bug and branch
368 # sharing polices to public.
369 owner = self.factory.makePerson()
370 with person_logged_in(owner):
371 product = getUtility(IProductSet).createProduct(
372 owner, 'carrot', 'Carrot', 'Carrot', 'testing',
373 licenses=[License.MIT])
374 self.assertEqual(BugSharingPolicy.PUBLIC, product.bug_sharing_policy)
375 self.assertEqual(
376 BranchSharingPolicy.PUBLIC, product.branch_sharing_policy)
377
378 def test_proprietary_product_creation_sharing_policies(self):
379 # Creating a new proprietary product sets the bug and branch sharing
380 # polices to proprietary.
381 owner = self.factory.makePerson()
382 with person_logged_in(owner):
383 product = getUtility(IProductSet).createProduct(
384 owner, 'carrot', 'Carrot', 'Carrot', 'testing',
385 licenses=[License.OTHER_PROPRIETARY])
386 self.assertEqual(
387 BugSharingPolicy.PROPRIETARY, product.bug_sharing_policy)
388 self.assertEqual(
389 BranchSharingPolicy.PROPRIETARY, product.branch_sharing_policy)
390
366391
367class TestProductBugInformationTypes(TestCaseWithFactory):392class TestProductBugInformationTypes(TestCaseWithFactory):
368393
@@ -387,7 +412,7 @@
387 def test_legacy_private_bugs(self):412 def test_legacy_private_bugs(self):
388 # The deprecated private_bugs attribute overrides the default413 # The deprecated private_bugs attribute overrides the default
389 # information type to USERDATA.414 # information type to USERDATA.
390 product = self.factory.makeProduct(private_bugs=True)415 product = self.factory.makeLegacyProduct(private_bugs=True)
391 self.assertContentEqual(416 self.assertContentEqual(
392 FREE_INFORMATION_TYPES, product.getAllowedBugInformationTypes())417 FREE_INFORMATION_TYPES, product.getAllowedBugInformationTypes())
393 self.assertEqual(418 self.assertEqual(
394419
=== modified file 'lib/lp/registry/tests/test_product_webservice.py'
--- lib/lp/registry/tests/test_product_webservice.py 2012-08-22 13:57:25 +0000
+++ lib/lp/registry/tests/test_product_webservice.py 2012-08-29 21:47:18 +0000
@@ -67,7 +67,7 @@
67 def test_branch_sharing_policy_non_commercial(self):67 def test_branch_sharing_policy_non_commercial(self):
68 # An API attempt to set a commercial-only branch_sharing_policy68 # An API attempt to set a commercial-only branch_sharing_policy
69 # on a non-commercial project returns Forbidden.69 # on a non-commercial project returns Forbidden.
70 product = self.factory.makeProduct()70 product = self.factory.makeLegacyProduct()
71 webservice = webservice_for_person(71 webservice = webservice_for_person(
72 product.owner, permission=OAuthPermission.WRITE_PRIVATE)72 product.owner, permission=OAuthPermission.WRITE_PRIVATE)
73 response = self.patch(73 response = self.patch(
@@ -93,7 +93,7 @@
93 def test_bug_sharing_policy_non_commercial(self):93 def test_bug_sharing_policy_non_commercial(self):
94 # An API attempt to set a commercial-only bug_sharing_policy94 # An API attempt to set a commercial-only bug_sharing_policy
95 # on a non-commercial project returns Forbidden.95 # on a non-commercial project returns Forbidden.
96 product = self.factory.makeProduct()96 product = self.factory.makeLegacyProduct()
97 webservice = webservice_for_person(97 webservice = webservice_for_person(
98 product.owner, permission=OAuthPermission.WRITE_PRIVATE)98 product.owner, permission=OAuthPermission.WRITE_PRIVATE)
99 response = self.patch(99 response = self.patch(
100100
=== modified file 'lib/lp/scripts/tests/test_garbo.py'
--- lib/lp/scripts/tests/test_garbo.py 2012-08-29 14:16:30 +0000
+++ lib/lp/scripts/tests/test_garbo.py 2012-08-29 21:47:18 +0000
@@ -1036,14 +1036,16 @@
1036 # set.1036 # set.
1037 with dbuser('testadmin'):1037 with dbuser('testadmin'):
1038 non_commercial_products = [1038 non_commercial_products = [
1039 self.factory.makeProduct()1039 self.factory.makeLegacyProduct()
1040 for i in range(10)]1040 for i in range(10)]
1041 commercial_project = self.factory.makeProduct()1041 commercial_project = self.factory.makeLegacyProduct()
1042 self.factory.makeCommercialSubscription(commercial_project)1042 self.factory.makeCommercialSubscription(commercial_project)
1043 configured_project = self.factory.makeProduct(1043 configured_project = self.factory.makeProduct(
1044 bug_sharing_policy=BugSharingPolicy.PROPRIETARY)1044 bug_sharing_policy=BugSharingPolicy.PROPRIETARY)
1045 private_project = self.factory.makeProduct(private_bugs=True)1045 removeSecurityProxy(
1046 project_with_bvp = self.factory.makeProduct()1046 configured_project).branch_sharing_policy = None
1047 private_project = self.factory.makeLegacyProduct(private_bugs=True)
1048 project_with_bvp = self.factory.makeLegacyProduct()
1047 project_with_bvp.setBranchVisibilityTeamPolicy(1049 project_with_bvp.setBranchVisibilityTeamPolicy(
1048 None, BranchVisibilityRule.FORBIDDEN)1050 None, BranchVisibilityRule.FORBIDDEN)
10491051
10501052
=== modified file 'lib/lp/testing/factory.py'
--- lib/lp/testing/factory.py 2012-08-28 00:00:47 +0000
+++ lib/lp/testing/factory.py 2012-08-29 21:47:18 +0000
@@ -137,6 +137,8 @@
137 IHWSubmissionSet,137 IHWSubmissionSet,
138 )138 )
139from lp.registry.enums import (139from lp.registry.enums import (
140 BranchSharingPolicy,
141 BugSharingPolicy,
140 DistroSeriesDifferenceStatus,142 DistroSeriesDifferenceStatus,
141 DistroSeriesDifferenceType,143 DistroSeriesDifferenceType,
142 InformationType,144 InformationType,
@@ -995,10 +997,27 @@
995 naked_product.driver = driver997 naked_product.driver = driver
996 if private_bugs:998 if private_bugs:
997 naked_product.private_bugs = private_bugs999 naked_product.private_bugs = private_bugs
1000 if ((branch_sharing_policy and
1001 branch_sharing_policy != BranchSharingPolicy.PUBLIC) or
1002 (bug_sharing_policy and
1003 bug_sharing_policy != BugSharingPolicy.PUBLIC)):
1004 self.makeCommercialSubscription(product)
998 if branch_sharing_policy:1005 if branch_sharing_policy:
999 naked_product.branch_sharing_policy = branch_sharing_policy1006 naked_product.setBranchSharingPolicy(branch_sharing_policy)
1000 if bug_sharing_policy:1007 if bug_sharing_policy:
1001 naked_product.bug_sharing_policy = bug_sharing_policy1008 naked_product.setBugSharingPolicy(bug_sharing_policy)
1009
1010 return product
1011
1012 def makeLegacyProduct(self, **kwargs):
1013 # Create a product which does not have any of the new bug and branch
1014 # sharing policies set. New products have these set to default values
1015 # but we need to test for existing products which have not yet been
1016 # migrated.
1017 # XXX This method can be removed when branch visibility policy dies.
1018 product = self.makeProduct(**kwargs)
1019 removeSecurityProxy(product).bug_sharing_policy = None
1020 removeSecurityProxy(product).branch_sharing_policy = None
1002 return product1021 return product
10031022
1004 def makeProductSeries(self, product=None, name=None, owner=None,1023 def makeProductSeries(self, product=None, name=None, owner=None,