Skip to content

Commit 008cb11

Browse files
Merge pull request sigmavirus24#631 from itsmemattchung/team_repo_permissions
Team repo permissions (re-recorded cassette for 625)
2 parents e0f6849 + 9b695ed commit 008cb11

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

AUTHORS.rst

Lines changed: 2 additions & 0 deletions
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

Lines changed: 4 additions & 2 deletions
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):
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"http_interactions": [{"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/1.0.0", "Accept-Charset": "utf-8", "Content-Type": "application/json", "Authorization": "Basic <BASIC_AUTH>"}, "method": "GET", "uri": "https://api.github.com/orgs/github3py"}, "response": {"body": {"string": "", "base64_string": "H4sIAAAAAAAAA52SPW/CMBCG/0rlOSROIFB5adcOVRekSl2iS3CMVce2bAdEEf+9ZxJKSie6Jed77+N570iUEVITRoQM276e2wNJiNwQlq8ei7xcJqR3Cp+3IVjPsgysTIfUtDFdZpzw2VTquDW+ukOTnRXYlO+4DvdJBwlqO97V3N0nHjXHbPg4YRnb10o21X+q/ZZOi8IOArhbJOegH1H2nrvG6IAAzlT7bKT/hENp6PjVn/RsECZZ0IdJWBoM12gmYbpXKkFfGwjSRGtfYSO90cnD+0vk3IFER4escezBA1b+IBDSB08YTUhrlDJ7hDv5kxrb4Ns2dOpmscltTM+icRwC31QQcJ6C5sWMlrNitaYLVpRsvvzAwXq7+ZWzmNHVrKDrfMkoZfMi5oSDjTDenAAtv4YFMWoCqMo6iVR5NS6D85m9xp5/45fIdUsE9Fn1HgRWz+kiElYKauMgmHH1WiqFi1cjPyJcCm2bQrRMpZ3UqTC7ZxHpRhPjOSlA/MeLg63jHKPeQoNd5nRVUJzxdrrT6Rvyb5wJlAMAAA==", "encoding": "utf-8"}, "headers": {"vary": "Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding", "x-served-by": "132026e9262a0093e437f99db5f1e499", "x-xss-protection": "1; mode=block", "x-content-type-options": "nosniff", "etag": "\"7a807b488b5268f40ea462dc5a957426\"", "access-control-allow-credentials": "true", "status": "200 OK", "x-ratelimit-remaining": "4976", "x-github-media-type": "github.v3; param=full; format=json", "access-control-expose-headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "transfer-encoding": "chunked", "x-github-request-id": "48A0C4D3:11E5:8BD47:53CEF47C", "cache-control": "private, max-age=60, s-maxage=60", "last-modified": "Sun, 20 Jul 2014 16:00:32 GMT", "date": "Tue, 22 Jul 2014 23:32:12 GMT", "access-control-allow-origin": "*", "content-security-policy": "default-src 'none'", "content-encoding": "gzip", "strict-transport-security": "max-age=31536000; includeSubdomains", "server": "GitHub.com", "x-ratelimit-limit": "5000", "x-frame-options": "deny", "content-type": "application/json; charset=utf-8", "x-ratelimit-reset": "1406073636"}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/orgs/github3py"}, "recorded_at": "2014-07-22T23:32:12"}, {"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/1.0.0", "Accept-Charset": "utf-8", "Content-Type": "application/json", "Authorization": "Basic <BASIC_AUTH>"}, "method": "GET", "uri": "https://api.github.com/teams/189901"}, "response": {"body": {"string": "", "base64_string": "H4sIAAAAAAAAA5VTyW7CMBT8lcrnLE4gUHzpuYeqF6RKvURO4gZL3uQFRBH/3kdiREBVCzf7+c1bZsYHpKhkiKD3nWLWoQTxDpHiebXCRYKcCD286fObYVZy57hWEKWd5AoAwQq4bbw3juQ5NTzrud+EJmu1zD2j0uVjPciVTDbQpr4bk0fEIR6OUMQyox332nL2SKUBNpmh1UF52DUWrOO9SpC2PVX8m/ph0QMSuodNCRr3mpn9mablc1lUi38ogGoun0KHQf6m4BqTn0dnW6b8Y9ARci/1N31/Id+ERvC2vkvIm2rX0KmidEs9tbeUDEEX3RQcs61WHggYjBXyYmT/BXaLHo4kZ4NAkGSo2l9ky7iGcANiIqKCEAno2kaN0RvtuNMqefp4hSQmKQdTj1lx7FEDAvaIgZ477xDBCfrSQujd6ftcblxBG3jbeCluFpt8j6ktWsuoZ11NwZSoxEWZ4iotl2s8J2VFZotPGCyY7ipnnuJlWuJ1sSAYk1l5yvF7M3zoqYmPxx8B305P6QMAAA==", "encoding": "utf-8"}, "headers": {"vary": "Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding", "x-served-by": "6d7de9e645814cac34ea2a8d72ba3141", "x-xss-protection": "1; mode=block", "x-content-type-options": "nosniff", "etag": "\"a7a21842a7b4f3bff9b46d086d6364aa\"", "access-control-allow-credentials": "true", "status": "200 OK", "x-ratelimit-remaining": "4975", "x-github-media-type": "github.v3; param=full; format=json", "access-control-expose-headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "transfer-encoding": "chunked", "x-github-request-id": "48A0C4D3:11E5:8BD98:53CEF47C", "cache-control": "private, max-age=60, s-maxage=60", "last-modified": "Sat, 20 Oct 2007 11:24:19 GMT", "date": "Tue, 22 Jul 2014 23:32:13 GMT", "access-control-allow-origin": "*", "content-security-policy": "default-src 'none'", "content-encoding": "gzip", "strict-transport-security": "max-age=31536000; includeSubdomains", "server": "GitHub.com", "x-ratelimit-limit": "5000", "x-frame-options": "deny", "content-type": "application/json; charset=utf-8", "x-ratelimit-reset": "1406073636"}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/teams/189901"}, "recorded_at": "2014-07-22T23:32:13"}, {"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Content-Length": "0", "Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/1.0.0", "Accept-Charset": "utf-8", "Content-Type": "application/json", "Authorization": "Basic <BASIC_AUTH>"}, "method": "PUT", "uri": "https://api.github.com/teams/189901/repos/github3py/urllib3"}, "response": {"body": {"string": "", "encoding": null}, "headers": {"status": "204 No Content", "x-ratelimit-remaining": "4974", "x-github-media-type": "github.v3; param=full; format=json", "x-content-type-options": "nosniff", "content-security-policy": "default-src 'none'", "access-control-expose-headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "x-github-request-id": "48A0C4D3:11E5:8BDCE:53CEF47D", "strict-transport-security": "max-age=31536000; includeSubdomains", "vary": "Accept-Encoding", "server": "GitHub.com", "access-control-allow-origin": "*", "x-ratelimit-limit": "5000", "x-served-by": "6d7de9e645814cac34ea2a8d72ba3141", "access-control-allow-credentials": "true", "date": "Tue, 22 Jul 2014 23:32:13 GMT", "x-frame-options": "deny", "x-xss-protection": "1; mode=block", "x-ratelimit-reset": "1406073636"}, "status": {"message": "No Content", "code": 204}, "url": "https://api.github.com/teams/189901/repos/github3py/urllib3"}, "recorded_at": "2014-07-22T23:32:13"}], "recorded_with": "betamax/{version}"}
1+
{"http_interactions": [{"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/1.0.0a4", "Accept-Charset": "utf-8", "Connection": "keep-alive", "Content-Type": "application/json", "Authorization": "Basic <BASIC_AUTH>"}, "method": "GET", "uri": "https://api.github.com/orgs/github3py"}, "response": {"body": {"string": "", "base64_string": "H4sIAAAAAAAAA52STY+bMBCG/0rFOeErkGwsVe21h6qXlSr1ggYwjrXGY9kmqzTKf+8YSMPuntgbjOeZj/eda6RQSB2xSEh/GuqduUSbSLYRyw5PeVbuN9FgFT2fvDeOJQkYGU+pcYN9gla4ZIlabtBVK5hkJKgpP3Pt16ETQuwJ8WUdOhJhVecGvg6dEGJ73tfcroNn5ppMHzcqY4Zayab6TLW36LIonMGDfW/EGHSzgYPjtkHtSfbRyyGZPf92/rqjuVruGiuNlxjugwIaev64lHg8FQIN6MsiLJHCNZ3VBClsYC7xE1rpUG++/P5BKbwHGS7rocB0CezwXxIhnXcRSzdRh0rhK4m9+JOaWtDbyffq3aKLC10eZ2M5eN5W4Klvnmb5Ni23+eE5LVhest3+D80ymPZNTrmltKx4zgpWPLFdGnL8xQQhflkBWv6d1qMoelCVsZJU5tW8DM2Hr5p6fozfI48tSZ6XanAgqHqWEdrQ2lCjBY/z6rVUihav7uoJG0PXxRAsVHEvdSzw/F0EbYOpQVwF5N/17l5nOaeoM9BQl+NhX+7z4nikvA+Dd9SLJnckGuleEjR9pbfbPyFBdBo4BAAA", "encoding": "utf-8"}, "headers": {"X-XSS-Protection": "1; mode=block", "Content-Security-Policy": "default-src 'none'", "Access-Control-Expose-Headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "Transfer-Encoding": "chunked", "Last-Modified": "Mon, 14 Dec 2015 14:48:30 GMT", "Access-Control-Allow-Origin": "*", "X-Frame-Options": "deny", "Status": "200 OK", "X-Served-By": "a241e1a8264a6ace03db946c85b92db3", "X-GitHub-Request-Id": "B97A8513:6CD8:89F2C95:5795B076", "ETag": "W/\"ca6f3da970261cac49205bd3bdc32764\"", "Date": "Mon, 25 Jul 2016 06:23:50 GMT", "X-RateLimit-Remaining": "4986", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", "Server": "GitHub.com", "X-GitHub-Media-Type": "github.v3; param=full; format=json", "X-Content-Type-Options": "nosniff", "Content-Encoding": "gzip", "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", "X-RateLimit-Limit": "5000", "Cache-Control": "private, max-age=60, s-maxage=60", "Content-Type": "application/json; charset=utf-8", "X-RateLimit-Reset": "1469430297"}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/orgs/github3py"}, "recorded_at": "2016-07-25T06:23:50"}, {"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/1.0.0a4", "Accept-Charset": "utf-8", "Connection": "keep-alive", "Content-Type": "application/json", "Authorization": "Basic <BASIC_AUTH>"}, "method": "GET", "uri": "https://api.github.com/teams/189901"}, "response": {"body": {"string": "", "base64_string": "H4sIAAAAAAAAA5VUy27qMBD9lWrWgTyAApaqrruouql0pbtBxnGDVb/kBxVF/PudJOY2RFULO/uMz2Qe5+QImioOBF4+NHceMhA1kHK1XhdlBl7GBmPmHKu5Z07YIIwGoqOUGVjulPC+Q4DWSmjMYZ3YU3ZAhEnjeY1QdBKvuxCsJ3lOrZg2IuzidsqMygOnyuf9V/Gt4mqLxWyu5uSJcUyHEyZx3BovgnGC35Kpow1qYCbqAKRKCTfpfp+BcQ3V4pP20ziCNA02T6Dva2YP52EuV1W5QMKP7WA2nw+pXSE/j+CSk59L53uuw23UnoIF74x5v43aMdpWvY+/TXpUcE+5duEj8jcrt3ErBdtcJZ9RtkvqUEd0TwN140V0oE8ajp47ZnTAsXdyjnnZ7/xx/zDD9i5sAwgkz6V1TzupINFS3XrmDAuD8BZlhRiepGFJa/BMa+GNzu7+PGGAKypac+ExtdErgSz/A43wwQMpMngzUpqP1upfN6HxExjbBSVHjQ5MOhQnc5wGXm8oWgOqoqwmxWJSLV+LOakWZHb/F2uJtr54s5jgs3L+Ws7JfEVmRfsmHGz38xla6XT6B6awTIKVBAAA", "encoding": "utf-8"}, "headers": {"X-XSS-Protection": "1; mode=block", "Content-Security-Policy": "default-src 'none'", "Access-Control-Expose-Headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "Transfer-Encoding": "chunked", "Last-Modified": "Mon, 14 Dec 2015 14:48:30 GMT", "Access-Control-Allow-Origin": "*", "X-Frame-Options": "deny", "Status": "200 OK", "X-Served-By": "b0ef53392caa42315c6206737946d931", "X-GitHub-Request-Id": "B97A8513:6CD8:89F2CA2:5795B076", "ETag": "W/\"031e1fbd47a0d445e26777c3f93303ba\"", "Date": "Mon, 25 Jul 2016 06:23:50 GMT", "X-RateLimit-Remaining": "4985", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", "Server": "GitHub.com", "X-GitHub-Media-Type": "github.v3; param=full; format=json", "X-Content-Type-Options": "nosniff", "Content-Encoding": "gzip", "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", "X-RateLimit-Limit": "5000", "Cache-Control": "private, max-age=60, s-maxage=60", "Content-Type": "application/json; charset=utf-8", "X-RateLimit-Reset": "1469430297"}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/teams/189901"}, "recorded_at": "2016-07-25T06:23:51"}, {"request": {"body": {"string": "{\"permission\": \"\"}", "encoding": "utf-8"}, "headers": {"Content-Length": "18", "Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/1.0.0a4", "Accept-Charset": "utf-8", "Connection": "keep-alive", "Content-Type": "application/json", "Authorization": "Basic <BASIC_AUTH>"}, "method": "PUT", "uri": "https://api.github.com/teams/189901/repos/github3py/urllib3"}, "response": {"body": {"string": "", "encoding": null}, "headers": {"Status": "204 No Content", "X-RateLimit-Remaining": "4984", "X-GitHub-Media-Type": "github.v3; param=full; format=json", "X-Content-Type-Options": "nosniff", "Content-Security-Policy": "default-src 'none'", "Access-Control-Expose-Headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "X-GitHub-Request-Id": "B97A8513:6CD8:89F2CB7:5795B076", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", "Vary": "Accept-Encoding", "X-Served-By": "7f48e2f7761567e923121f17538d7a6d", "Server": "GitHub.com", "X-XSS-Protection": "1; mode=block", "X-RateLimit-Limit": "5000", "Date": "Mon, 25 Jul 2016 06:23:50 GMT", "X-Frame-Options": "deny", "Access-Control-Allow-Origin": "*", "X-RateLimit-Reset": "1469430297"}, "status": {"message": "No Content", "code": 204}, "url": "https://api.github.com/teams/189901/repos/github3py/urllib3"}, "recorded_at": "2016-07-25T06:23:51"}], "recorded_with": "betamax/0.7.1"}

tests/unit/test_orgs_team.py

Lines changed: 7 additions & 1 deletion
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy