-
Notifications
You must be signed in to change notification settings - Fork 395
/
test_orgs_team.py
99 lines (84 loc) · 3.9 KB
/
test_orgs_team.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
"""Integration tests for methods implemented on Team."""
import github3
from .helper import IntegrationHelper
class TestTeam(IntegrationHelper):
"""Team integration tests."""
betamax_kwargs = {"match_requests_on": ["method", "uri", "json-body"]}
def setUp(self):
super().setUp()
self.auto_login()
def get_organization(self, organization="github3py"):
"""Get the desired organization."""
o = self.gh.organization(organization)
assert isinstance(o, github3.orgs.Organization)
return o
def get_team(self, organization="github3py", id=189901):
"""Get our desired team."""
o = self.get_organization(organization)
t = o.team(id)
assert isinstance(t, github3.orgs.Team)
return t
def test_add_repository(self):
"""Show that a user can add a repository to a team."""
cassette_name = self.cassette_name("add_repository")
with self.recorder.use_cassette(cassette_name):
team = self.get_team()
assert team.add_repository("github3py/urllib3") is True
def test_delete(self):
"""Show that a user can delete a team."""
cassette_name = self.cassette_name("delete")
with self.recorder.use_cassette(cassette_name):
o = self.get_organization()
t = o.create_team("delete-me")
assert isinstance(t, github3.orgs.Team)
assert t.delete() is True
def test_edit(self):
"""Show that a user can edit a team."""
cassette_name = self.cassette_name("edit")
with self.recorder.use_cassette(cassette_name):
o = self.get_organization()
# Create a new team to play with
t = o.create_team("edit-me", privacy="closed")
p = o.create_team("parent", privacy="closed")
assert isinstance(t, github3.orgs.Team)
# Edit the new team
assert t.edit("delete-me", parent_team_id=p.id) is True
# Assert that the name has changed
assert t.name == "delete-me"
# Get rid of it, we don't need it.
assert t.delete() is True
assert p.delete() is True
def test_has_repository(self):
"""Show that a user can check of a team has access to a repository."""
cassette_name = self.cassette_name("has_repository")
with self.recorder.use_cassette(cassette_name):
t = self.get_team()
assert t.has_repository("github3py/urllib3") is True
def test_members(self):
"""Show that a user can retrieve a team's members."""
cassette_name = self.cassette_name("members")
with self.recorder.use_cassette(cassette_name):
t = self.get_team()
for member in t.members():
assert isinstance(member, github3.users.ShortUser)
def test_can_filter_members_by_role(self):
"""Test the ability to filter an team's members by role."""
self.auto_login()
cassette_name = self.cassette_name("members_roles")
with self.recorder.use_cassette(cassette_name):
t = self.get_team()
for member in t.members(role="all"):
assert isinstance(member, github3.users.ShortUser)
def test_repositories(self):
"""Show that a user can retrieve a team's repositories."""
cassette_name = self.cassette_name("repositories")
with self.recorder.use_cassette(cassette_name):
t = self.get_team()
for repository in t.repositories():
assert isinstance(repository, github3.repos.ShortRepository)
def test_remove_repository(self):
"""Show a user can remove a repository from a team."""
cassette_name = self.cassette_name("remove_repository")
with self.recorder.use_cassette(cassette_name):
team = self.get_team(id=923595)
assert team.remove_repository("github3py/urllib3") is True