Skip to content

Commit

Permalink
Merge pull request #1076 from sigmavirus24/support-adding-parents-to-…
Browse files Browse the repository at this point in the history
…teams

Support adding parents to teams
  • Loading branch information
sigmavirus24 committed Feb 21, 2022
2 parents dccad7d + 3c965e3 commit 28abf6d
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 11 deletions.
11 changes: 11 additions & 0 deletions docs/source/release-notes/3.1.1.rst
@@ -0,0 +1,11 @@
3.1.1: 2022-02-21
-----------------

Features Added
``````````````

- Support editing parent team and team visibility via
:meth:`github3.orgs.Team.edit`

- Added more allowed statuses to Deployments for
:meth:`github3.repos.deployment.Deployment.create_status()`
3 changes: 0 additions & 3 deletions docs/source/release-notes/3.2.0.rst
Expand Up @@ -8,9 +8,6 @@ Dependency Change
Features Added
``````````````

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


Bug Fixes
`````````
1 change: 1 addition & 0 deletions docs/source/release-notes/index.rst
Expand Up @@ -10,6 +10,7 @@ here with the newest releases first.

.. toctree::
3.2.0
3.1.1
3.1.0
3.0.0

Expand Down
5 changes: 5 additions & 0 deletions setup.cfg
Expand Up @@ -23,6 +23,11 @@ classifiers =
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: Implementation :: CPython
project_urls =
Documentation = https://github3.readthedocs.io
Changelog = https://github3.readthedocs.io/en/latest/release-notes/index.html
Source = https://github3.com/sigmavirus24/github3.py
Released Versions = https://github.com/sigmavirus24/github3.py/tags
requires_dist =
requests>=2.0
uritemplate>=3.0.0
Expand Down
2 changes: 1 addition & 1 deletion src/github3/__about__.py
Expand Up @@ -5,7 +5,7 @@
__author_email__ = "graffatcolmingov@gmail.com"
__license__ = "Modified BSD"
__copyright__ = "Copyright 2012-2022 Ian Stapleton Cordasco"
__version__ = "3.1.0"
__version__ = "3.1.1"
__version_info__ = tuple(
int(i) for i in __version__.split(".") if i.isdigit()
)
Expand Down
23 changes: 21 additions & 2 deletions src/github3/orgs.py
Expand Up @@ -118,20 +118,39 @@ def delete(self):
return self._boolean(self._delete(self._api), 204, 404)

@requires_auth
def edit(self, name, permission=""):
def edit(
self,
name: str,
permission: str = "",
parent_team_id: t.Optional[int] = None,
privacy: t.Optional[str] = None,
):
"""Edit this team.
:param str name:
(required), the new name of this team
:param str permission:
(optional), one of ('pull', 'push', 'admin')
.. deprecated:: 3.0.0
This was deprecated by the GitHub API.
:param int parent_team_id:
(optional), id of the parent team for this team
:param str privacy:
(optional), one of "closed" or "secret"
:returns:
True if successful, False otherwise
:rtype:
bool
"""
if name:
data = {"name": name, "permission": permission}
data = {"name": name}
if permission:
data["permission"] = permission
if parent_team_id is not None:
data["parent_team_id"] = parent_team_id
if privacy in {"closed", "secret"}:
data["privacy"] = privacy
json = self._json(self._patch(self._api, data=dumps(data)), 200)
if json:
self._update_attributes(json)
Expand Down
2 changes: 1 addition & 1 deletion tests/cassettes/Team_edit.json

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions tests/integration/test_orgs_team.py
Expand Up @@ -48,14 +48,16 @@ def test_edit(self):
with self.recorder.use_cassette(cassette_name):
o = self.get_organization()
# Create a new team to play with
t = o.create_team("edit-me")
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") is True
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."""
Expand Down
9 changes: 7 additions & 2 deletions tests/unit/test_orgs_team.py
Expand Up @@ -33,10 +33,15 @@ def test_delete(self):

def test_edit(self):
"""Show that a user can edit a team."""
self.instance.edit("name", "admin")
self.instance.edit("name", "admin", 1234)

self.patch_called_with(
url_for(), data={"name": "name", "permission": "admin"}
url_for(),
data={
"name": "name",
"permission": "admin",
"parent_team_id": 1234,
},
)

def test_has_repository(self):
Expand Down

0 comments on commit 28abf6d

Please sign in to comment.