launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #11958
[Merge] lp:~deryck/launchpad/use-specification-sharing-policy into lp:launchpad
Deryck Hodge has proposed merging lp:~deryck/launchpad/use-specification-sharing-policy into lp:launchpad with lp:~deryck/launchpad/specification-sharing-policy-unused as a prerequisite.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~deryck/launchpad/use-specification-sharing-policy/+merge/124240
To start making use of SpecificationSharingPolicy, this branch updates or adds the methods getAllowedSpecificationInformationTypes and getDefaultSpecificationInformationType. This is largely a branch that adds tests and fixes these methods on Product. All we really care about for Specifications is Products, but I also updated the methods on Distribution to return Public for those objects.
To get this working, I needed to add SPECIFICATION_POLICY_DEFAULT_TYPES to make sure the defaults were correct. Also, there is no QA for this since it's just tests and model changes. We're also lint free. The LOC count is justified since this is for the disclosure project which already has approval for LOC increase.
--
https://code.launchpad.net/~deryck/launchpad/use-specification-sharing-policy/+merge/124240
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~deryck/launchpad/use-specification-sharing-policy into lp:launchpad.
=== modified file 'lib/lp/blueprints/interfaces/specificationtarget.py'
--- lib/lp/blueprints/interfaces/specificationtarget.py 2012-09-07 19:40:53 +0000
+++ lib/lp/blueprints/interfaces/specificationtarget.py 2012-09-13 16:09:21 +0000
@@ -111,7 +111,10 @@
"""
def getAllowedSpecificationInformationTypes():
- """Get the InformationTypes for this targets' specifications."""
+ """Get the InformationTypes for this target's specifications."""
+
+ def getDefaultSpecificationInformationType():
+ """Get the default InformationType for the target's specifications."""
class ISpecificationGoal(ISpecificationTarget):
=== modified file 'lib/lp/blueprints/model/specification.py'
--- lib/lp/blueprints/model/specification.py 2012-09-13 16:09:21 +0000
+++ lib/lp/blueprints/model/specification.py 2012-09-13 16:09:21 +0000
@@ -10,6 +10,7 @@
'recursive_dependent_query',
'Specification',
'SPECIFICATION_POLICY_ALLOWED_TYPES',
+ 'SPECIFICATION_POLICY_DEFAULT_TYPES',
'SpecificationSet',
]
@@ -140,6 +141,17 @@
[InformationType.PROPRIETARY, InformationType.EMBARGOED],
}
+SPECIFICATION_POLICY_DEFAULT_TYPES = {
+ SpecificationSharingPolicy.PUBLIC: InformationType.PUBLIC,
+ SpecificationSharingPolicy.PUBLIC_OR_PROPRIETARY: (
+ InformationType.PUBLIC),
+ SpecificationSharingPolicy.PROPRIETARY_OR_PUBLIC: (
+ InformationType.PROPRIETARY),
+ SpecificationSharingPolicy.PROPRIETARY: InformationType.PROPRIETARY,
+ SpecificationSharingPolicy.EMBARGOED_OR_PROPRIETARY: (
+ InformationType.EMBARGOED),
+ }
+
class Specification(SQLBase, BugLinkTargetMixin):
"""See ISpecification."""
=== modified file 'lib/lp/registry/model/distribution.py'
--- lib/lp/registry/model/distribution.py 2012-09-11 19:14:06 +0000
+++ lib/lp/registry/model/distribution.py 2012-09-13 16:09:21 +0000
@@ -979,6 +979,10 @@
"""See `ISpecificationTarget`."""
return (InformationType.PUBLIC,)
+ def getDefaultSpecificationInformationType(self):
+ """See `ISpecificationTarget`."""
+ return InformationType.PUBLIC
+
def searchQuestions(self, search_text=None,
status=QUESTION_STATUS_DEFAULT_SEARCH,
language=None, sort=None, owner=None,
=== modified file 'lib/lp/registry/model/product.py'
--- lib/lp/registry/model/product.py 2012-09-13 16:09:21 +0000
+++ lib/lp/registry/model/product.py 2012-09-13 16:09:21 +0000
@@ -87,6 +87,7 @@
HasSpecificationsMixin,
Specification,
SPECIFICATION_POLICY_ALLOWED_TYPES,
+ SPECIFICATION_POLICY_DEFAULT_TYPES,
)
from lp.blueprints.model.sprint import HasSprintsMixin
from lp.bugs.interfaces.bugsummary import IBugSummaryDimension
@@ -124,7 +125,6 @@
InformationType,
PRIVATE_INFORMATION_TYPES,
SpecificationSharingPolicy,
- PUBLIC_PROPRIETARY_INFORMATION_TYPES,
)
from lp.registry.errors import CommercialSubscribersOnly
from lp.registry.interfaces.accesspolicy import (
@@ -629,7 +629,17 @@
def getAllowedSpecificationInformationTypes(self):
"""See `ISpecificationTarget`."""
- return PUBLIC_PROPRIETARY_INFORMATION_TYPES
+ if self.specification_sharing_policy is not None:
+ return SPECIFICATION_POLICY_ALLOWED_TYPES[
+ self.specification_sharing_policy]
+ return [InformationType.PUBLIC]
+
+ def getDefaultSpecificationInformationType(self):
+ """See `ISpecificationTarget`."""
+ if self.specification_sharing_policy is not None:
+ return SPECIFICATION_POLICY_DEFAULT_TYPES[
+ self.specification_sharing_policy]
+ return InformationType.PUBLIC
def _ensurePolicies(self, information_types):
# Ensure that the product has access policies for the specified
=== modified file 'lib/lp/registry/tests/test_distribution.py'
--- lib/lp/registry/tests/test_distribution.py 2012-09-05 06:48:36 +0000
+++ lib/lp/registry/tests/test_distribution.py 2012-09-13 16:09:21 +0000
@@ -286,6 +286,22 @@
InformationType.PUBLIC,
self.factory.makeDistribution().getDefaultBugInformationType())
+ def test_getAllowedSpecificationInformationTypes(self):
+ # All distros currently support only public specifications.
+ distro = self.factory.makeDistribution()
+ self.assertContentEqual(
+ [InformationType.PUBLIC],
+ distro.getAllowedSpecificationInformationTypes()
+ )
+
+ def test_getDefaultSpecificationInformtationType(self):
+ # All distros currently support only Public by default
+ # specifications.
+ distro = self.factory.makeDistribution()
+ self.assertEqual(
+ InformationType.PUBLIC,
+ distro.getDefaultSpecificationInformationType())
+
class TestDistributionCurrentSourceReleases(
CurrentSourceReleasesMixin, TestCase):
=== modified file 'lib/lp/registry/tests/test_product.py'
--- lib/lp/registry/tests/test_product.py 2012-09-03 01:35:58 +0000
+++ lib/lp/registry/tests/test_product.py 2012-09-13 16:09:21 +0000
@@ -34,6 +34,7 @@
FREE_INFORMATION_TYPES,
INCLUSIVE_TEAM_POLICY,
InformationType,
+ SpecificationSharingPolicy,
)
from lp.registry.errors import (
CommercialSubscribersOnly,
@@ -459,6 +460,86 @@
product.getDefaultBugInformationType())
+class TestProductSpecificationPolicyAndInformationTypes(TestCaseWithFactory):
+
+ layer = DatabaseFunctionalLayer
+
+ def makeProductWithPolicy(self, specification_sharing_policy):
+ product = self.factory.makeProduct()
+ self.factory.makeCommercialSubscription(product=product)
+ with person_logged_in(product.owner):
+ product.setSpecificationSharingPolicy(
+ specification_sharing_policy)
+ return product
+
+ def test_no_policy(self):
+ # Projects that have not specified a policy can use the PUBLIC
+ # information type.
+ product = self.factory.makeProduct()
+ self.assertContentEqual(
+ [InformationType.PUBLIC],
+ product.getAllowedSpecificationInformationTypes())
+ self.assertEqual(
+ InformationType.PUBLIC,
+ product.getDefaultSpecificationInformationType())
+
+ def test_sharing_policy_public(self):
+ # Projects with a purely public policy should use PUBLIC
+ # information type.
+ product = self.makeProductWithPolicy(
+ SpecificationSharingPolicy.PUBLIC)
+ self.assertContentEqual(
+ [InformationType.PUBLIC],
+ product.getAllowedSpecificationInformationTypes())
+ self.assertEqual(
+ InformationType.PUBLIC,
+ product.getDefaultSpecificationInformationType())
+
+ def test_sharing_policy_public_or_proprietary(self):
+ # specification_sharing_policy can enable Proprietary.
+ product = self.makeProductWithPolicy(
+ SpecificationSharingPolicy.PUBLIC_OR_PROPRIETARY)
+ self.assertContentEqual(
+ [InformationType.PUBLIC, InformationType.PROPRIETARY],
+ product.getAllowedSpecificationInformationTypes())
+ self.assertEqual(
+ InformationType.PUBLIC,
+ product.getDefaultSpecificationInformationType())
+
+ def test_sharing_policy_proprietary_or_public(self):
+ # specification_sharing_policy can enable and default to Proprietary.
+ product = self.makeProductWithPolicy(
+ SpecificationSharingPolicy.PROPRIETARY_OR_PUBLIC)
+ self.assertContentEqual(
+ [InformationType.PUBLIC, InformationType.PROPRIETARY],
+ product.getAllowedSpecificationInformationTypes())
+ self.assertEqual(
+ InformationType.PROPRIETARY,
+ product.getDefaultSpecificationInformationType())
+
+ def test_sharing_policy_proprietary(self):
+ # specification_sharing_policy can enable only Proprietary.
+ product = self.makeProductWithPolicy(
+ SpecificationSharingPolicy.PROPRIETARY)
+ self.assertContentEqual(
+ [InformationType.PROPRIETARY],
+ product.getAllowedSpecificationInformationTypes())
+ self.assertEqual(
+ InformationType.PROPRIETARY,
+ product.getDefaultSpecificationInformationType())
+
+ def test_sharing_policy_embargoed_or_proprietary(self):
+ # specification_sharing_policy can be embargoed and then proprietary.
+ product = self.makeProductWithPolicy(
+ SpecificationSharingPolicy.EMBARGOED_OR_PROPRIETARY)
+ self.assertContentEqual(
+ [InformationType.PROPRIETARY, InformationType.EMBARGOED],
+ product.getAllowedSpecificationInformationTypes())
+ self.assertEqual(
+ InformationType.EMBARGOED,
+ product.getDefaultSpecificationInformationType())
+
+
class ProductPermissionTestCase(TestCaseWithFactory):
layer = DatabaseFunctionalLayer
Follow ups