Skip to content

Commit 4cbe771

Browse files
committed
add test for repo.add_collaborator(user, perm)
1 parent 3dd990c commit 4cbe771

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

AUTHORS.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,5 @@ Contributors
216216
- Philipp Heil (@zkdev)
217217

218218
- Petter Kvalvaag (@pettermk)
219+
220+
- Peter Küffner (@kuepe-sl)

src/github3/repos/repo.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,10 @@ def add_collaborator(self, username, permission=None):
126126
:type username:
127127
str or :class:`~github3.users.User`
128128
:param str permission:
129-
(optional), permission to grant the collaborator, valid on organization repositories only
130-
Can be 'pull', 'triage', 'push', 'maintain', 'admin' or an organization-defined custom role name.
129+
(optional), permission to grant the collaborator, valid on
130+
organization repositories only.
131+
Can be 'pull', 'triage', 'push', 'maintain', 'admin' or an
132+
organization-defined custom role name.
131133
:returns:
132134
True if successful, False otherwise
133135
:rtype:

tests/unit/test_repos_repo.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,16 @@ def test_add_collaborator(self):
8181
url_for("collaborators/sigmavirus24")
8282
)
8383

84+
def test_add_collaborator_with_permission(self):
85+
"""Verify the request to add a collaborator to a repository with
86+
`admin` permission."""
87+
self.instance.add_collaborator("sigmavirus24", "admin")
88+
89+
self.session.put.assert_called_once_with(
90+
url_for("collaborators/sigmavirus24"),
91+
data='{"permission": "admin"}'
92+
)
93+
8494
def test_add_null_collaborator(self):
8595
"""Verify no request is made when adding `None` as a collaborator."""
8696
self.instance.add_collaborator(None)

0 commit comments

Comments
 (0)