← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wgrant/launchpad/branchnamespace-information-type into lp:launchpad

 

William Grant has proposed merging lp:~wgrant/launchpad/branchnamespace-information-type into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/branchnamespace-information-type/+merge/114387

This branch prepares IBranchNamespace for the BranchVisibilityPolicy replacement. Branch privacy is no longer a binary thing; we want to be able to enable different sets of information types depending on new project configuration.

This does not yet change any behaviour. The namespace implementations still allow combinations of PUBLIC_INFORMATION_TYPES and PRIVATE_INFORMATION_TYPES, and ProductNamespace still uses BranchVisibilityPolicy. But it's the majority of the work toward an interface that can operate on both BVP and the new config system.

Some callsites are only minimally shimmed around the new getAllowedInformationTypes method. A more complete port will come in a subsequent branch.
-- 
https://code.launchpad.net/~wgrant/launchpad/branchnamespace-information-type/+merge/114387
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/branchnamespace-information-type into lp:launchpad.
=== modified file 'lib/lp/code/errors.py'
--- lib/lp/code/errors.py	2012-05-24 02:16:59 +0000
+++ lib/lp/code/errors.py	2012-07-11 11:03:34 +0000
@@ -8,8 +8,6 @@
     'AlreadyLatestFormat',
     'BadBranchMergeProposalSearchContext',
     'BadStateTransition',
-    'BranchCannotBePrivate',
-    'BranchCannotBePublic',
     'BranchCannotChangeInformationType',
     'BranchCreationException',
     'BranchCreationForbidden',
@@ -148,14 +146,6 @@
     """
 
 
-class BranchCannotBePublic(Exception):
-    """The branch cannot be made public."""
-
-
-class BranchCannotBePrivate(Exception):
-    """The branch cannot be made private."""
-
-
 class BranchCannotChangeInformationType(Exception):
     """The information type of this branch cannot be changed."""
 

=== modified file 'lib/lp/code/interfaces/branchnamespace.py'
--- lib/lp/code/interfaces/branchnamespace.py	2011-03-03 01:13:47 +0000
+++ lib/lp/code/interfaces/branchnamespace.py	2012-07-11 11:03:34 +0000
@@ -110,6 +110,12 @@
         :return: A Boolean value.
         """
 
+    def getAllowedInformationTypes():
+        """Get the information types that a branch in this namespace can have.
+
+        :return: A sequence of `InformationType`s.
+        """
+
     def areNewBranchesPrivate():
         """Are new branches in this namespace private?
 
@@ -118,22 +124,6 @@
         :return: A Boolean value.
         """
 
-    def canBranchesBePrivate():
-        """Can branches by the user be private in this namespace?
-
-        No check is made about whether or not a user can create branches.
-
-        :return: A Boolean value.
-        """
-
-    def canBranchesBePublic():
-        """Can branches by the user be public in this namespace?
-
-        No check is made about whether or not a user can create branches.
-
-        :return: A Boolean value.
-        """
-
     def validateRegistrant(registrant):
         """Check that the registrant can create a branch on this namespace.
 

=== modified file 'lib/lp/code/model/branch.py'
--- lib/lp/code/model/branch.py	2012-07-10 09:51:13 +0000
+++ lib/lp/code/model/branch.py	2012-07-11 11:03:34 +0000
@@ -83,8 +83,6 @@
     )
 from lp.code.errors import (
     AlreadyLatestFormat,
-    BranchCannotBePrivate,
-    BranchCannotBePublic,
     BranchCannotChangeInformationType,
     BranchMergeProposalExists,
     BranchTargetError,
@@ -248,14 +246,11 @@
             and self.stacked_on.information_type in PRIVATE_INFORMATION_TYPES
             and information_type in PUBLIC_INFORMATION_TYPES):
             raise BranchCannotChangeInformationType()
-        private = information_type in PRIVATE_INFORMATION_TYPES
         # Only check the privacy policy if the user is not special.
         if verify_policy and not user_has_special_branch_access(who):
             policy = IBranchNamespacePolicy(self.namespace)
-            if private and not policy.canBranchesBePrivate():
-                raise BranchCannotBePrivate()
-            if not private and not policy.canBranchesBePublic():
-                raise BranchCannotBePublic()
+            if information_type not in policy.getAllowedInformationTypes():
+                raise BranchCannotChangeInformationType()
         self.information_type = information_type
         self._reconcileAccess()
         if information_type in PRIVATE_INFORMATION_TYPES:
@@ -1300,13 +1295,15 @@
     def canBePublic(self, user):
         """See `IBranch`."""
         policy = IBranchNamespacePolicy(self.namespace)
-        return policy.canBranchesBePublic()
+        return InformationType.PUBLIC in policy.getAllowedInformationTypes()
 
     def canBePrivate(self, user):
         """See `IBranch`."""
         policy = IBranchNamespacePolicy(self.namespace)
         # Do the easy checks first.
-        if (policy.canBranchesBePrivate() or
+        policy_allows = (
+            InformationType.USERDATA in policy.getAllowedInformationTypes())
+        if (policy_allows or
                 user_has_special_branch_access(user) or
                 user.visibility == PersonVisibility.PRIVATE):
             return True

=== modified file 'lib/lp/code/model/branchnamespace.py'
--- lib/lp/code/model/branchnamespace.py	2012-06-14 09:09:59 +0000
+++ lib/lp/code/model/branchnamespace.py	2012-07-11 11:03:34 +0000
@@ -44,7 +44,11 @@
     )
 from lp.code.interfaces.branchtarget import IBranchTarget
 from lp.code.model.branch import Branch
-from lp.registry.enums import InformationType
+from lp.registry.enums import (
+    InformationType,
+    PRIVATE_INFORMATION_TYPES,
+    PUBLIC_INFORMATION_TYPES,
+    )
 from lp.registry.errors import (
     NoSuchDistroSeries,
     NoSuchSourcePackageName,
@@ -261,18 +265,13 @@
         else:
             return True
 
+    def getAllowedInformationTypes(self):
+        """See `IBranchNamespace`."""
+        raise NotImplementedError
+
     def areNewBranchesPrivate(self):
         """See `IBranchNamespace`."""
-        # Always delegates to canBranchesBePrivate for now.
-        return self.canBranchesBePrivate()
-
-    def canBranchesBePrivate(self):
-        """See `IBranchNamespace`."""
-        raise NotImplementedError(self.canBranchesBePrivate)
-
-    def canBranchesBePublic(self):
-        """See `IBranchNamespace`."""
-        raise NotImplementedError(self.canBranchesBePublic)
+        return InformationType.USERDATA in self.getAllowedInformationTypes()
 
     def getPrivacySubscriber(self):
         """See `IBranchNamespace`."""
@@ -307,17 +306,14 @@
         """See `IBranchNamespace`."""
         return '~%s/+junk' % self.owner.name
 
-    def canBranchesBePrivate(self):
-        """See `IBranchNamespace`."""
-        private = False
-        if self.owner.is_team and (
-            self.owner.visibility == PersonVisibility.PRIVATE):
-            private = True
-        return private
-
-    def canBranchesBePublic(self):
-        """See `IBranchNamespace`."""
-        return True
+    def getAllowedInformationTypes(self):
+        """See `IBranchNamespace`."""
+        # Private teams get private branches, everyone else gets public ones.
+        if (self.owner.is_team
+            and self.owner.visibility == PersonVisibility.PRIVATE):
+            return PUBLIC_INFORMATION_TYPES + PRIVATE_INFORMATION_TYPES
+        else:
+            return PUBLIC_INFORMATION_TYPES
 
     def getPrivacySubscriber(self):
         """See `IBranchNamespace`."""
@@ -395,33 +391,39 @@
         base_rule = self.product.getBaseBranchVisibilityRule()
         return base_rule == BranchVisibilityRule.PUBLIC
 
-    def canBranchesBePrivate(self):
+    def getAllowedInformationTypes(self):
         """See `IBranchNamespace`."""
-        # If there is a rule for the namespace owner, use that.
-        private = (
+        private_rules = (
             BranchVisibilityRule.PRIVATE,
             BranchVisibilityRule.PRIVATE_ONLY)
-        rule = self.product.getBranchVisibilityRuleForTeam(self.owner)
-        if rule is not None:
-            return rule in private
-        # If the owner is a member of any team that has a PRIVATE or
-        # PRIVATE_ONLY rule, then the branches are private.
-        return len(self._getRelatedPrivatePolicies()) > 0
-
-    def canBranchesBePublic(self):
-        """See `IBranchNamespace`."""
-        # If there is an explicit rule for the namespace owner, use that.
-        rule = self.product.getBranchVisibilityRuleForTeam(self.owner)
-        if rule is not None:
-            return rule != BranchVisibilityRule.PRIVATE_ONLY
-        # If there is another policy that allows public, then branches can be
-        # public.
-        for policy in self._getRelatedPolicies():
-            if policy.rule != BranchVisibilityRule.PRIVATE_ONLY:
-                return True
-        # If the default is public, then we can have public branches.
-        base_rule = self.product.getBaseBranchVisibilityRule()
-        return base_rule == BranchVisibilityRule.PUBLIC
+
+        rule = self.product.getBranchVisibilityRuleForTeam(self.owner)
+        if rule is not None:
+            # If there is an explicit rule for the namespace owner, use that.
+            private = rule in private_rules
+            public = rule != BranchVisibilityRule.PRIVATE_ONLY
+        else:
+            # Otherwise find all the rules for the owner's teams.
+            related_rules = set(p.rule for p in self._getRelatedPolicies())
+
+            # If any of the rules allow private branches, allow them.
+            private = bool(related_rules.intersection(private_rules))
+
+            # If any of the rules allow public branches, allow them.
+            if related_rules.difference([BranchVisibilityRule.PRIVATE_ONLY]):
+                public = True
+            else:
+                # There's no team-specific rules, or none of them allow
+                # public branches. Fall back to the default rule.
+                base_rule = self.product.getBaseBranchVisibilityRule()
+                public = base_rule == BranchVisibilityRule.PUBLIC
+
+        types = []
+        if public:
+            types.extend(PUBLIC_INFORMATION_TYPES)
+        if private:
+            types.extend(PRIVATE_INFORMATION_TYPES)
+        return types
 
 
 class PackageNamespace(_BaseNamespace):
@@ -453,13 +455,9 @@
         """See `IBranchNamespace`."""
         return IBranchTarget(self.sourcepackage)
 
-    def canBranchesBePrivate(self):
-        """See `IBranchNamespace`."""
-        return False
-
-    def canBranchesBePublic(self):
-        """See `IBranchNamespace`."""
-        return True
+    def getAllowedInformationTypes(self):
+        """See `IBranchNamespace`."""
+        return PUBLIC_INFORMATION_TYPES
 
     def getPrivacySubscriber(self):
         """See `IBranchNamespace`."""

=== modified file 'lib/lp/code/model/tests/test_branch.py'
--- lib/lp/code/model/tests/test_branch.py	2012-07-09 00:18:47 +0000
+++ lib/lp/code/model/tests/test_branch.py	2012-07-11 11:03:34 +0000
@@ -54,8 +54,6 @@
     )
 from lp.code.errors import (
     AlreadyLatestFormat,
-    BranchCannotBePrivate,
-    BranchCannotBePublic,
     BranchCannotChangeInformationType,
     BranchCreatorNotMemberOfOwnerTeam,
     BranchCreatorNotOwner,
@@ -2419,10 +2417,10 @@
 
     def test_public_to_private_not_allowed(self):
         # If there are no privacy policies allowing private branches, then
-        # BranchCannotBePrivate is rasied.
+        # BranchCannotChangeInformationType is rasied.
         branch = self.factory.makeProductBranch()
         self.assertRaises(
-            BranchCannotBePrivate,
+            BranchCannotChangeInformationType,
             branch.setPrivate,
             True, branch.owner)
 
@@ -2460,7 +2458,8 @@
 
     def test_private_to_public_not_allowed(self):
         # If the namespace policy does not allow public branches, attempting
-        # to change the branch to be public raises BranchCannotBePublic.
+        # to change the branch to be public raises
+        # BranchCannotChangeInformationType.
         branch = self.factory.makeProductBranch(
             information_type=InformationType.USERDATA)
         branch.product.setBranchVisibilityTeamPolicy(
@@ -2468,7 +2467,7 @@
         branch.product.setBranchVisibilityTeamPolicy(
             branch.owner, BranchVisibilityRule.PRIVATE_ONLY)
         self.assertRaises(
-            BranchCannotBePublic,
+            BranchCannotChangeInformationType,
             branch.setPrivate,
             False, branch.owner)
 

=== modified file 'lib/lp/code/model/tests/test_branchnamespace.py'
--- lib/lp/code/model/tests/test_branchnamespace.py	2012-06-08 06:01:50 +0000
+++ lib/lp/code/model/tests/test_branchnamespace.py	2012-07-11 11:03:34 +0000
@@ -35,7 +35,11 @@
     PersonalNamespace,
     ProductNamespace,
     )
-from lp.registry.enums import InformationType
+from lp.registry.enums import (
+    InformationType,
+    PRIVATE_INFORMATION_TYPES,
+    PUBLIC_INFORMATION_TYPES,
+    )
 from lp.registry.errors import (
     NoSuchDistroSeries,
     NoSuchSourcePackageName,
@@ -974,8 +978,8 @@
             BranchVisibilityRule.PRIVATE_ONLY)
 
 
-class TestPersonalNamespaceCanBranchesBePrivate(TestCaseWithFactory):
-    """Tests for PersonalNamespace.canBranchesBePrivate."""
+class TestPersonalNamespaceAllowedInformationTypes(TestCaseWithFactory):
+    """Tests for PersonalNamespace.getAllowedInformationTypes."""
 
     layer = DatabaseFunctionalLayer
 
@@ -983,61 +987,44 @@
         # +junk branches are not private for individuals
         person = self.factory.makePerson()
         namespace = PersonalNamespace(person)
-        self.assertFalse(namespace.canBranchesBePrivate())
+        self.assertContentEqual(
+            PUBLIC_INFORMATION_TYPES,
+            namespace.getAllowedInformationTypes())
 
     def test_public_team(self):
         # +junk branches for public teams cannot be private
         team = self.factory.makeTeam()
         namespace = PersonalNamespace(team)
-        self.assertFalse(namespace.canBranchesBePrivate())
+        self.assertContentEqual(
+            PUBLIC_INFORMATION_TYPES,
+            namespace.getAllowedInformationTypes())
 
     def test_private_team(self):
-        # +junk branches can be private for private teams
+        # +junk branches can be private or public for private teams
         team = self.factory.makeTeam(visibility=PersonVisibility.PRIVATE)
         namespace = PersonalNamespace(team)
-        self.assertTrue(namespace.canBranchesBePrivate())
-
-
-class TestPersonalNamespaceCanBranchesBePublic(TestCaseWithFactory):
-    """Tests for PersonalNamespace.canBranchesBePublic."""
-
-    layer = DatabaseFunctionalLayer
-
-    def test_anyone(self):
-        # All +junk branches are public.
-        person = self.factory.makePerson()
-        namespace = PersonalNamespace(person)
-        self.assertTrue(namespace.canBranchesBePublic())
-
-
-class TestPackageNamespaceCanBranchesBePrivate(TestCaseWithFactory):
-    """Tests for PackageNamespace.canBranchesBePrivate."""
-
-    layer = DatabaseFunctionalLayer
-
-    def test_anyone(self):
-        # No source package branches are private.
-        source_package = self.factory.makeSourcePackage()
-        person = self.factory.makePerson()
-        namespace = PackageNamespace(person, source_package)
-        self.assertFalse(namespace.canBranchesBePrivate())
-
-
-class TestPackageNamespaceCanBranchesBePublic(TestCaseWithFactory):
-    """Tests for PackageNamespace.canBranchesBePublic."""
-
-    layer = DatabaseFunctionalLayer
-
-    def test_anyone(self):
-        # All source package branches are public.
-        source_package = self.factory.makeSourcePackage()
-        person = self.factory.makePerson()
-        namespace = PackageNamespace(person, source_package)
-        self.assertTrue(namespace.canBranchesBePublic())
-
-
-class TestProductNamespaceCanBranchesBePrivate(TestCaseWithFactory):
-    """Tests for ProductNamespace.canBranchesBePrivate."""
+        self.assertContentEqual(
+            PUBLIC_INFORMATION_TYPES + PRIVATE_INFORMATION_TYPES,
+            namespace.getAllowedInformationTypes())
+
+
+class TestPackageNamespaceAllowedInformationTypes(TestCaseWithFactory):
+    """Tests for PackageNamespace.getAllowedInformationTypes."""
+
+    layer = DatabaseFunctionalLayer
+
+    def test_anyone(self):
+        # Source package branches are always public.
+        source_package = self.factory.makeSourcePackage()
+        person = self.factory.makePerson()
+        namespace = PackageNamespace(person, source_package)
+        self.assertContentEqual(
+            PUBLIC_INFORMATION_TYPES,
+            namespace.getAllowedInformationTypes())
+
+
+class TestProductNamespaceAllowedInformationTypes(TestCaseWithFactory):
+    """Tests for ProductNamespace.getAllowedInformationTypes."""
 
     layer = DatabaseFunctionalLayer
 
@@ -1048,33 +1035,26 @@
     def _getNamespace(self, owner):
         return ProductNamespace(owner, self.product)
 
-    def assertNewBranchesPublic(self, owner):
-        # Assert that new branches in the owner namespace are public.
-        namespace = self._getNamespace(owner)
-        self.assertFalse(namespace.canBranchesBePrivate())
-
-    def assertNewBranchesPrivate(self, owner):
-        # Assert that new branches in the owner namespace are private.
-        namespace = self._getNamespace(owner)
-        self.assertTrue(namespace.canBranchesBePrivate())
+    def assertTypes(self, owner, types):
+        namespace = self._getNamespace(owner)
+        self.assertContentEqual(types, namespace.getAllowedInformationTypes())
 
     def test_no_policies(self):
         # If there are no defined policies, any personal branch is not
         # private.
-        self.assertNewBranchesPublic(self.factory.makePerson())
+        self.assertTypes(self.factory.makePerson(), PUBLIC_INFORMATION_TYPES)
 
     def test_any_person_with_public_base_rule(self):
         # If the base visibility rule is PUBLIC, then new branches are public.
         self.product.setBranchVisibilityTeamPolicy(
             None, BranchVisibilityRule.PUBLIC)
-        self.assertNewBranchesPublic(self.factory.makePerson())
+        self.assertTypes(self.factory.makePerson(), PUBLIC_INFORMATION_TYPES)
 
     def test_any_person_with_forbidden_base_rule(self):
-        # If the base visibility rule is FORBIDDEN, new branches are still
-        # considered public.
+        # If the base visibility rule is FORBIDDEN, there are no legal types.
         self.product.setBranchVisibilityTeamPolicy(
             None, BranchVisibilityRule.FORBIDDEN)
-        self.assertNewBranchesPublic(self.factory.makePerson())
+        self.assertTypes(self.factory.makePerson(), [])
 
     def test_team_member_with_private_rule(self):
         # If a person is a member of a team that has a PRIVATE rule, then new
@@ -1083,8 +1063,10 @@
         team = self.factory.makeTeam(owner=person)
         self.product.setBranchVisibilityTeamPolicy(
             team, BranchVisibilityRule.PRIVATE)
-        self.assertNewBranchesPrivate(person)
-        self.assertNewBranchesPrivate(team)
+        self.assertTypes(
+            person, PUBLIC_INFORMATION_TYPES + PRIVATE_INFORMATION_TYPES)
+        self.assertTypes(
+            team, PUBLIC_INFORMATION_TYPES + PRIVATE_INFORMATION_TYPES)
 
     def test_team_member_with_private_only_rule(self):
         # If a person is a member of a team that has a PRIVATE_ONLY rule, then
@@ -1092,9 +1074,11 @@
         person = self.factory.makePerson()
         team = self.factory.makeTeam(owner=person)
         self.product.setBranchVisibilityTeamPolicy(
+            None, BranchVisibilityRule.FORBIDDEN)
+        self.product.setBranchVisibilityTeamPolicy(
             team, BranchVisibilityRule.PRIVATE_ONLY)
-        self.assertNewBranchesPrivate(person)
-        self.assertNewBranchesPrivate(team)
+        self.assertTypes(person, PRIVATE_INFORMATION_TYPES)
+        self.assertTypes(team, PRIVATE_INFORMATION_TYPES)
 
     def test_non_team_member_with_private_rule(self):
         # If a person is a not a member of a team that has a privacy rule,
@@ -1103,7 +1087,7 @@
         team = self.factory.makeTeam(owner=person)
         self.product.setBranchVisibilityTeamPolicy(
             team, BranchVisibilityRule.PRIVATE)
-        self.assertNewBranchesPublic(self.factory.makePerson())
+        self.assertTypes(self.factory.makePerson(), PUBLIC_INFORMATION_TYPES)
 
     def test_team_member_with_multiple_private_rules(self):
         # If a person is a member of multiple teams that has a privacy rules,
@@ -1115,9 +1099,12 @@
             team_1, BranchVisibilityRule.PRIVATE)
         self.product.setBranchVisibilityTeamPolicy(
             team_2, BranchVisibilityRule.PRIVATE)
-        self.assertNewBranchesPrivate(person)
-        self.assertNewBranchesPrivate(team_1)
-        self.assertNewBranchesPrivate(team_2)
+        self.assertTypes(
+            person, PUBLIC_INFORMATION_TYPES + PRIVATE_INFORMATION_TYPES)
+        self.assertTypes(
+            team_1, PUBLIC_INFORMATION_TYPES + PRIVATE_INFORMATION_TYPES)
+        self.assertTypes(
+            team_2, PUBLIC_INFORMATION_TYPES + PRIVATE_INFORMATION_TYPES)
 
     def test_team_member_with_multiple_differing_private_rules(self):
         # If a person is a member of multiple teams that has a privacy rules,
@@ -1131,103 +1118,12 @@
             private_team, BranchVisibilityRule.PRIVATE)
         self.product.setBranchVisibilityTeamPolicy(
             public_team, BranchVisibilityRule.PUBLIC)
-        self.assertNewBranchesPrivate(person)
-        self.assertNewBranchesPrivate(private_team)
-        self.assertNewBranchesPublic(public_team)
-
-
-class TestProductNamespaceCanBranchesBePublic(TestCaseWithFactory):
-    """Tests for ProductNamespace.canBranchesBePublic."""
-
-    layer = DatabaseFunctionalLayer
-
-    def setUp(self):
-        TestCaseWithFactory.setUp(self)
-        self.product = self.factory.makeProduct()
-
-    def _getNamespace(self, owner):
-        return ProductNamespace(owner, self.product)
-
-    def assertBranchesCanBePublic(self, owner):
-        # Assert that branches can be public in the owner namespace.
-        namespace = self._getNamespace(owner)
-        self.assertTrue(namespace.canBranchesBePublic())
-
-    def assertBranchesMustBePrivate(self, owner):
-        # Assert that branches must be private in the owner namespace.
-        namespace = self._getNamespace(owner)
-        self.assertFalse(namespace.canBranchesBePublic())
-
-    def test_no_policies(self):
-        # If there are no defined policies, any branch can be public.
-        self.assertBranchesCanBePublic(self.factory.makePerson())
-
-    def test_any_person_with_public_base_rule(self):
-        # If the base visibility rule is PUBLIC, any branch can be public
-        self.product.setBranchVisibilityTeamPolicy(
-            None, BranchVisibilityRule.PUBLIC)
-        self.assertBranchesCanBePublic(self.factory.makePerson())
-
-    def test_any_person_with_forbidden_base_rule(self):
-        # If the base visibility rule is FORBIDDEN, branches must be private.
-        self.product.setBranchVisibilityTeamPolicy(
-            None, BranchVisibilityRule.FORBIDDEN)
-        self.assertBranchesMustBePrivate(self.factory.makePerson())
-
-    def test_team_member_with_private_rule(self):
-        # If a person is a member of a team that has a PRIVATE rule then the
-        # branches can be public even though the default is FORBIDDEN.
-        person = self.factory.makePerson()
-        team = self.factory.makeTeam(owner=person)
-        self.product.setBranchVisibilityTeamPolicy(
-            None, BranchVisibilityRule.FORBIDDEN)
-        self.product.setBranchVisibilityTeamPolicy(
-            team, BranchVisibilityRule.PRIVATE)
-        self.assertBranchesCanBePublic(person)
-        self.assertBranchesCanBePublic(team)
-
-    def test_team_member_with_private_only_rule(self):
-        # If a person is a member of a team that has a PRIVATE_ONLY rule, and
-        # the base rule is FORBIDDEN, then the branches must be private.
-        person = self.factory.makePerson()
-        team = self.factory.makeTeam(owner=person)
-        self.product.setBranchVisibilityTeamPolicy(
-            None, BranchVisibilityRule.FORBIDDEN)
-        self.product.setBranchVisibilityTeamPolicy(
-            team, BranchVisibilityRule.PRIVATE_ONLY)
-        self.assertBranchesMustBePrivate(person)
-        self.assertBranchesMustBePrivate(team)
-
-    def test_team_member_with_private_only_rule_public_base_rule(self):
-        # If a person is a member of a team that has a PRIVATE_ONLY rule, and
-        # the base rule is PUBLIC, then the branches must be private in the
-        # team namespace, but can be public in the personal namespace.
-        person = self.factory.makePerson()
-        team = self.factory.makeTeam(owner=person)
-        self.product.setBranchVisibilityTeamPolicy(
-            None, BranchVisibilityRule.PUBLIC)
-        self.product.setBranchVisibilityTeamPolicy(
-            team, BranchVisibilityRule.PRIVATE_ONLY)
-        self.assertBranchesCanBePublic(person)
-        self.assertBranchesMustBePrivate(team)
-
-    def test_team_member_with_multiple_private_rules(self):
-        # If a person is a member of multiple teams that has a privacy rules,
-        # then new branches must stay private in any namespace that defines
-        # PRIVATE_ONLY, but if the team member is a member of any teams that
-        # specify just PRIVATE, then branches can be made public.
-        person = self.factory.makePerson()
-        team_1 = self.factory.makeTeam(owner=person)
-        team_2 = self.factory.makeTeam(owner=person)
-        self.product.setBranchVisibilityTeamPolicy(
-            None, BranchVisibilityRule.FORBIDDEN)
-        self.product.setBranchVisibilityTeamPolicy(
-            team_1, BranchVisibilityRule.PRIVATE_ONLY)
-        self.product.setBranchVisibilityTeamPolicy(
-            team_2, BranchVisibilityRule.PRIVATE)
-        self.assertBranchesCanBePublic(person)
-        self.assertBranchesMustBePrivate(team_1)
-        self.assertBranchesCanBePublic(team_2)
+        self.assertTypes(
+            person, PUBLIC_INFORMATION_TYPES + PRIVATE_INFORMATION_TYPES)
+        self.assertTypes(
+            private_team,
+            PUBLIC_INFORMATION_TYPES + PRIVATE_INFORMATION_TYPES)
+        self.assertTypes(public_team, PUBLIC_INFORMATION_TYPES)
 
 
 class BaseValidateNewBranchMixin:
@@ -1389,7 +1285,8 @@
         :param owner: The person or team that will be the owner of the branch.
         """
         namespace = get_branch_namespace(owner, product=self.product)
-        self.assertFalse(namespace.canBranchesBePrivate())
+        self.assertNotIn(
+            InformationType.USERDATA, namespace.getAllowedInformationTypes())
 
     def assertPrivateSubscriber(self, creator, owner, subscriber):
         """Assert that the policy check results in a private branch.
@@ -1400,7 +1297,8 @@
         """
         policy = IBranchNamespacePolicy(
             get_branch_namespace(owner, product=self.product))
-        self.assertTrue(policy.canBranchesBePrivate())
+        self.assertIn(
+            InformationType.USERDATA, policy.getAllowedInformationTypes())
         if subscriber is None:
             self.assertIs(None, policy.getPrivacySubscriber())
         else:


Follow ups