Skip to content

Commit c20489d

Browse files
author
Evan Borgstrom
committed
Allow adding repos to teams with specific permissions
1 parent e0f6849 commit c20489d

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

AUTHORS.rst

+2
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,5 @@ Contributors
130130
- Dejan Svetec (@dsvetec)
131131

132132
- Billy Keyes (@bluekeyes)
133+
134+
- Evan Borgstrom (@borgstrom)

github3/orgs.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,16 @@ def add_member(self, username):
7878
return self._boolean(self._put(url), 204, 404)
7979

8080
@requires_auth
81-
def add_repository(self, repository):
81+
def add_repository(self, repository, permission=''):
8282
"""Add ``repository`` to this team.
8383
8484
:param str repository: (required), form: 'user/repo'
85+
:param str permission: (optional), ('pull', 'push', 'admin')
8586
:returns: bool
8687
"""
88+
data = {'permission': permission}
8789
url = self._build_url('repos', repository, base_url=self._api)
88-
return self._boolean(self._put(url), 204, 404)
90+
return self._boolean(self._put(url, data=dumps(data)), 204, 404)
8991

9092
@requires_auth
9193
def delete(self):

tests/unit/test_orgs_team.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ def test_add_repository(self):
2424
"""Show that one can add a repository to an organization team."""
2525
self.instance.add_repository('name-of-repo')
2626

27-
self.session.put.assert_called_once_with(url_for('repos/name-of-repo'))
27+
self.put_called_with(url_for('repos/name-of-repo'),
28+
data={'permission': ''})
29+
30+
self.instance.add_repository('name-of-repo', permission='push')
31+
32+
self.put_called_with(url_for('repos/name-of-repo'),
33+
data={'permission': 'push'})
2834

2935
def test_delete(self):
3036
"""Show that a user can delete an organization team."""

0 commit comments

Comments
 (0)