119
117
person=team, subscribed_by=subscribed_by)
120
118
self.assertTrue(subscription.canBeUnsubscribedByUser(subscribed_by))
124
return unittest.TestLoader().loadTestsFromName(__name__)
120
def test_branch_person_owner_can_unsubscribe(self):
121
"""Branch owner can unsubscribe someone from a branch."""
122
branch_owner = self.factory.makePerson()
123
branch = self.factory.makeBranch(owner=branch_owner)
124
subscribed_by = self.factory.makePerson()
125
subscriber = self.factory.makePerson()
126
subscription = self.factory.makeBranchSubscription(
127
branch=branch, person=subscriber, subscribed_by=subscribed_by)
128
self.assertTrue(subscription.canBeUnsubscribedByUser(branch_owner))
130
def test_branch_team_owner_can_unsubscribe(self):
131
"""Branch team owner can unsubscribe someone from a branch.
133
If the owner of a branch is a team, then the team members can
136
team_owner = self.factory.makePerson()
137
team_member = self.factory.makePerson()
138
branch_owner = self.factory.makeTeam(
139
owner=team_owner, members=[team_member])
140
branch = self.factory.makeBranch(owner=branch_owner)
141
subscribed_by = self.factory.makePerson()
142
subscriber = self.factory.makePerson()
143
subscription = self.factory.makeBranchSubscription(
144
branch=branch, person=subscriber, subscribed_by=subscribed_by)
145
self.assertTrue(subscription.canBeUnsubscribedByUser(team_owner))
146
self.assertTrue(subscription.canBeUnsubscribedByUser(team_member))