8000 Merge pull request #1076 from sigmavirus24/support-adding-parents-to-… · sarahmonod/github3.py@28abf6d · GitHub
[go: up one dir, main page]

Skip to content

Commit 28abf6d

Browse files
authored
Merge pull request sigmavirus24#1076 from sigmavirus24/support-adding-parents-to-teams
Support adding parents to teams
2 parents dccad7d + 3c965e3 commit 28abf6d

File tree

9 files changed

+51
-11
lines changed

9 files changed

+51
-11
lines changed

docs/source/release-notes/3.1.1.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
3.1.1: 2022-02-21
2+
-----------------
3+
4+
Features Added
5+
``````````````
6+
7+
- Support editing parent team and team visibility via
8+
:meth:`github3.orgs.Team.edit`
9+
10+
- Added more allowed statuses to Deployments for
11+
:meth:`github3.repos.deployment.Deployment.create_status()`

docs/source/release-notes/3.2.0.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ Dependency Change
88
Features Added
99
``````````````
1010

11-
- Added more allowed statuses to Deployments for
12-
:meth:`github3.repos.deployment.Deployment.create_status()`
13-
1411

1512
Bug Fixes
1613
`````````

docs/source/release-notes/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ here with the newest releases first.
1010

1111
.. toctree::
1212
3.2.0
13+
3.1.1
1314
3.1.0
1415
3.0.0
1516

setup.cfg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ classifiers =
2323
Programming Language :: Python :: 3.9
2424
Programming Language :: Python :: 3.10
2525
Programming Language :: Python :: Implementation :: CPython
26+
project_urls =
27+
Documentation = https://github3.readthedocs.io
28+
Changelog = https://github3.readthedocs.io/en/latest/release-notes/index.html
29+
Source = https://github3.com/sigmavirus24/github3.py
30+
Released Versions = https://github.com/sigmavirus24/github3.py/tags
2631
requires_dist =
2732
requests>=2.0
2833
uritemplate>=3.0.0

src/github3/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
__author_email__ = "graffatcolmingov@gmail.com"
66
__license__ = "Modified BSD"
77
__copyright__ = "Copyright 2012-2022 Ian Stapleton Cordasco"
8-
__version__ = "3.1.0"
8+
__version__ = "3.1.1"
99
__version_info__ = tuple(
1010
int(i) for i in __version__.split(".") if i.isdigit()
1111
)

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)
0