Skip to content

Commit 4e11e8f

Browse files
committed
Support adding parent teams
Support adding a parent team to a given team. Also support changing the privacy of a team.
1 parent dccad7d commit 4e11e8f

File tree

4 files changed

+33
-7
lines changed

4 files changed

+33
-7
lines changed

src/github3/orgs.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,20 +118,39 @@ def delete(self):
118118
return self._boolean(self._delete(self._api), 204, 404)
119119

120120
@requires_auth
121-
def edit(self, name, permission=""):
121+
def edit(
122+
self,
123+
name: str,
124+
permission: str = "",
125+
parent_team_id: t.Optional[int] = None,
126+
privacy: t.Optional[str] = None,
127+
):
122128
"""Edit this team.
123129
124130
:param str name:
125131
(required), the new name of this team
126132
:param str permission:
127133
(optional), one of ('pull', 'push', 'admin')
134+
.. deprecated:: 3.0.0
135+
136+
This was deprecated by the GitHub API.
137+
:param int parent_team_id:
138+
(optional), id of the parent team for this team
139+
:param str privacy:
140+
(optional), one of "closed" or "secret"
128141
:returns:
129142
True if successful, False otherwise
130143
:rtype:
131144
bool
132145
"""
133146
if name:
134-
data = {"name": name, "permission": permission}
147+
data = {"name": name}
148+
if permission:
149+
data["permission"] = permission
150+
if parent_team_id is not None:
151+
data["parent_team_id"] = parent_team_id
152+
if privacy in {"closed", "secret"}:
153+
data["privacy"] = privacy
135154
json = self._json(self._patch(self._api, data=dumps(data)), 200)
136155
if json:
137156
self._update_attributes(json)

tests/cassettes/Team_edit.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

tests/integration/test_orgs_team.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,16 @@ def test_edit(self):
4848
with self.recorder.use_cassette(cassette_name):
4949
o = self.get_organization()
5050
# Create a new team to play with
51-
t = o.create_team("edit-me")
51+
t = o.create_team("edit-me", privacy="closed")
52+
p = o.create_team("parent", privacy="closed")
5253
assert isinstance(t, github3.orgs.Team)
5354
# Edit the new team
54-
assert t.edit("delete-me") is True
55+
assert t.edit("delete-me", parent_team_id=p.id) is True
5556
# Assert that the name has changed
5657
assert t.name == "delete-me"
5758
# Get rid of it, we don't need it.
5859
assert t.delete() is True
60+
assert p.delete() is True
5961

6062
def test_has_repository(self):
6163
"""Show that a user can check of a team has access to a repository."""

tests/unit/test_orgs_team.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,15 @@ def test_delete(self):
3333

3434
def test_edit(self):
3535
"""Show that a user can edit a team."""
36-
self.instance.edit("name", "admin")
36+
self.instance.edit("name", "admin", 1234)
3737

3838
self.patch_called_with(
39-
url_for(), data={"name": "name", "permission": "admin"}
39+
url_for(),
40+
data={
41+
"name": "name",
42+
"permission": "admin",
43+
"parent_team_id": 1234,
44+
},
4045
)
4146

4247
def test_has_repository(self):

0 commit comments

Comments
 (0)