This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conflicts: gratipay/models/team/__init__.py gratipay/models/team/mixins/__init__.py gratipay/models/team/mixins/membership.py
- Loading branch information
1 parent
1d484ad
commit 8e4ca75
Showing
5 changed files
with
107 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
from __future__ import absolute_import, division, print_function, unicode_literals | ||
|
||
from test_team_takes import TeamTakesHarness | ||
from gratipay.models.team import mixins | ||
|
||
|
||
class Tests(TeamTakesHarness): | ||
|
||
def setUp(self): | ||
TeamTakesHarness.setUp(self) | ||
|
||
def assert_memberships(self, *expected): | ||
actual = self.enterprise.get_memberships() | ||
assert [m['username'] for m in actual] == list(expected) | ||
|
||
|
||
def test_team_object_subclasses_takes_mixin(self): | ||
assert isinstance(self.enterprise, mixins.Membership) | ||
|
||
|
||
# gm - get_memberships | ||
|
||
def test_gm_returns_an_empty_list_when_there_are_no_members(self): | ||
assert self.enterprise.get_memberships() == [] | ||
|
||
def test_gm_returns_memberships_when_there_are_members(self): | ||
self.enterprise.add_member(self.crusher, self.picard) | ||
assert len(self.enterprise.get_memberships()) == 1 | ||
|
||
def test_gm_returns_more_memberships_when_there_are_more_members(self): | ||
self.enterprise.add_member(self.crusher, self.picard) | ||
self.enterprise.add_member(self.bruiser, self.picard) | ||
assert len(self.enterprise.get_memberships()) == 2 | ||
|
||
|
||
# am - add_member | ||
|
||
def test_am_adds_a_member(self): | ||
self.enterprise.add_member(self.crusher, self.picard) | ||
self.assert_memberships('crusher') | ||
|
||
def test_am_adds_another_member(self): | ||
self.enterprise.add_member(self.crusher, self.picard) | ||
self.enterprise.add_member(self.bruiser, self.picard) | ||
self.assert_memberships('crusher', 'bruiser') | ||
|
||
def test_am_affects_computed_values_as_expected(self): | ||
self.enterprise.add_member(self.crusher, self.picard) | ||
self.enterprise.add_member(self.bruiser, self.picard) | ||
assert self.enterprise.nmembers == 2 | ||
|
||
|
||
# rm - remove_member | ||
|
||
def test_rm_removes_a_member(self): | ||
self.enterprise.add_member(self.crusher, self.picard) | ||
self.enterprise.add_member(self.bruiser, self.picard) | ||
self.enterprise.remove_member(self.crusher, self.crusher) | ||
self.assert_memberships('bruiser') | ||
|
||
def test_rm_removes_another_member(self): | ||
self.enterprise.add_member(self.crusher, self.picard) | ||
self.enterprise.add_member(self.bruiser, self.picard) | ||
self.enterprise.remove_member(self.crusher, self.crusher) | ||
self.enterprise.remove_member(self.bruiser, self.picard) | ||
self.assert_memberships() | ||
|
||
def test_rm_affects_computed_values_as_expected(self): | ||
self.enterprise.add_member(self.crusher, self.picard) | ||
self.enterprise.add_member(self.bruiser, self.picard) | ||
self.enterprise.remove_member(self.crusher, self.crusher) | ||
assert self.enterprise.nmembers == 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters