8000 Added Collaborator, Contributor and Repository.collaborators(affiliation) by AndreasBackx · Pull Request #731 · sigmavirus24/github3.py · GitHub
[go: up one dir, main page]

Skip to content

Added Collaborator, Contributor and Repository.collaborators(affiliation) #731

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions github3/repos/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,21 +280,35 @@ def code_frequency(self, number=-1, etag=None):
url = self._build_url('stats', 'code_frequency', base_url=self._api)
return self._iter(int(number), url, list, etag=etag)

def collaborators(self, number=-1, etag=None):
def collaborators(self, affiliation='all', number=-1, etag=None):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The affiliations parameter should be documented here.

"""Iterate over the collaborators of this repository.

:param str affiliation:
(optional), affiliation of the collaborator to the repository.
Default: "all" returns contributors with all affiliations
:param int number:
(optional), number of collaborators to return.
Default: -1 returns all comments
:param str etag:
(optional), ETag from a previous request to the same endpoint
:returns:
generator of collaborator users
generator of collaborators
:rtype:
:class:`~github3.users.ShortUser`
:class:`~github3.users.Collaborator`
"""
url = self._build_url('collaborators', base_url=self._api)
return self._iter(int(number), url, users.ShortUser, etag=etag)
affiliations = {'outside', 'direct', 'all'}
if affiliation not in affiliations:
raise ValueError(
(
"Invalid affiliation value {!r} parameter passed, must "
"be 'outside', 'direct', or 'all' (defaults to 'all')."
).format(affiliation)
)
params = {'affiliation': affiliation}
return self._iter(
int(number), url, users.Collaborator, params, etag=etag
)

def comments(self, number=-1, etag=None):
"""Iterate over comments on all commits in the repository.
Expand Down
78 changes: 54 additions & 24 deletions github3/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,30 +505,6 @@ def delete(self):
return self._boolean(self._delete(url), 204, 403)


class Contributor(_User):
"""Object for the specialized representation of a contributor.

When retrieving a repository's contributors, GitHub returns the same
information as a :class:`~github3.users.ShortUser` with an additional
attribute:

.. versionadded:: 1.0.0

This class was added in version 1.0.0

.. attribute:: contributions_count

The number of contributions a contributor has made to the repository

"""

class_name = 'Contributor'

def _update_attributes(self, contributor):
super(Contributor, self)._update_attributes(contributor)
self.contributions = contributor['contributions']


class User(_User):
"""Object for the full representation of a User.

Expand Down Expand Up @@ -765,3 +741,57 @@ def _update_attributes(self, user):
self.plan = user.get('plan')
if self.plan is not None:
self.plan = Plan(self.plan, self)


class Collaborator(_User):
"""Object for the representation of a collaborator.

.. versionadded:: 1.1.0

When retrieving a repository's contributors, GitHub returns the same
information as a :class:`~github3.users.ShortUser` with an additional
attribute:

.. attribute:: permissions

Admin, push, and pull permissions of a collaborator
"""

class_name = 'Collaborator'
_refresh_to = User

def _update_attributes(self, user):
super(Collaborator, self)._update_attributes(user)

self.permissions = user['permissions']


class Contributor(_User):
"""Object for the specialized representation of a contributor.

.. versionadded:: 1.0.0

.. versionchanged:: 1.1.0

This class now refreshes to a :class:`~github3.users.User`.

The attribute ``contributions`` was renamed to ``contributions_count``,
the documentation already declared it as ``contributions_count``, it
was the implementation now reflects this as well.

When retrieving a repository's contributors, GitHub returns the same
information as a :class:`~github3.users.ShortUser` with an additional
attribute:

.. attribute:: contributions_count

The number of contributions a contributor has made to the repository

"""

class_name = 'Contributor'
_refresh_to = User

def _update_attributes(self, contributor):
super(Contributor, self)._update_attributes(contributor)
self.contributions_count = contributor['contributions']
2 changes: 1 addition & 1 deletion tests/cassettes/Repository_collaborators.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"http_interactions": [{"request": {"body": {"encoding": "utf-8", "string": ""}, "headers": {"User-Agent": "github3.py/1.0.0a4", "Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.drax-preview+json", "Connection": "keep-alive", "Accept-Charset": "utf-8", "Content-Type": "application/json", "Authorization": "token <AUTH_TOKEN>"}, "method": "GET", "uri": "https://api.github.com/repos/sigmavirus24/github3.py"}, "response": {"body": {"encoding": "utf-8", "base64_string": "H4sIAAAAAAAAA62YQXPqNhDHvwrjawnGmDyIZzqvPbU99R3SSy+MsAVWY1uuJEOJJ9+9/5VssHlTSKJeGGNrf1qtdle7agORBUm8iuarKJoGFSt5kAR7YfJmG8/qUzANdk1RbLoPWuxLdhCq0YtlOBoljxVXQdIGhdyLCozhUFBomsVyvo7n04AdmGFq06gC43Jjap2EoXup45nDNpqrVFaGV2aWyjJsQif99fDjEri96iDEDfDiClaLjuOEAdPhlUa5KYsrHdzUVuRq8E4WhTyCcq31vYnCsySZ0lJEtf8kBZJtKE3OYTws6Y0MIbT5uFJWqsUOarMRGXE0dkTx7MOKdXJQixzgrQ0Vr6UFNludKlEbIauPKziSBk2qPavEK/scDdIaEFLt46pYKUjzA3zx4+JOrA1rJQ4sPZFpFE+5OMDYn0ReyYNoTjXF7R9wCjK9MHzDspLicMcKzd+mgZ3eYJB9MUXYvdf7x3Ge8fOuYsJvJ5PLalKIrWLqNNlJNRGIWbVjKXx1ckQemcBdJ78I82uznfz87bdDDAUx7uWsyc3ItcYfBeNYHSLd2ZObCIQnAFDphZ+8OCTfhvjt4ilFqLOtVMzIe0njtoIjUBsO/5IvGc5KL8UtAKBcSj9LWgBAQuuGv8u1by/ccnTYx0/VlFuX8t4TNbfRjgBdmUaerzj3suAZ0oZ9VkY4VGnuh+0Zbeie7G6zvZeqJA/MtpBbLw4OytBC2lDnzJ1DZuOrHVGJMYIqvvNWlRhnqFGe+23VJMgZiUPQYOu99OwZYdtZtGDVvmF7P+oZgl2no3rPXu8WMbdj50IBkio0JbaNf5K7cEhTVzsg3v1MesFcoLYguV3m3DHAoLCxJihLca8uuE3sECO3/x+w5KfXaPp/v4y5ry4x2vCSk13S7+g+1u2yfq/ncI6uHfByiZ4Rtj/UzOSUuTBVzRT3UbpDhO2WodiazWZtzpktq0uuPCPYEYBiKs1RNfro2fYMVD0lM7Za35GaGar3QrLMy7ZnCIBuG310dYTh/tdoRL0UtIAhsRQF10ZWfjn2QhmyK2nETqTv6Vhuh9sI1H7Vokr5lBXFFF5rRCrgx6i1aRdRcHI/CzkCloF7ANepFBwu7WV1xR2jDV2nmfG6kCfvLDTAUBArju4m2zCDrmQxjxYP8/ghip+jp+RxnTzGf2JMU2ejMasHDFusn+fL5PFLsrRj6kbnA4wb8vQcxfieRF9oCNJq59d4wsUFfnFZ8t2lwaBPoasICGqdXwR/uogl/3Gr0omlBRz0KpLeP+fh+qy7LwpVc1nyGrXH4H7GycX1aQZTZ2jqMpnqmZC0MPGKkdF6FT2NqoxUNhX2Y7VcToMjMyiIcZ4PX/bVybmTpKmZ3rjYDxKjGmpV8aZW8i+eGj18d8k3g4FH8SIuTS5JUgl1fuP6xU6HxWqNDC2Ukt1lVIUEcU60uFjqemVZ86rTqVc/mseIN5HySmPpLbWPWIS9msEautuy37u/us7+QVsYJI5vG156RFvu2s/EajKYBtakCXqjdTbM+I41hdm4fgDzZWhkClmT33JVwmp010LqdM2/sx/5dG83SoHuGZMjicjjRv/dMHimPWf6Ye6LfYUVU4Ez/qI4nXRjmYqbI5rp3kJ2ScNCrjN6vHz7F5xWtG51FAAA", "string": ""}, "headers": {"Server": "GitHub.com", "Date": "Mon, 01 Jan 2018 21:12:31 GMT", "Content-Type": "application/json; charset=utf-8", "Transfer-Encoding": "chunked", "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4997", "X-RateLimit-Reset": "1514844517", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", "ETag": "W/\"5c2f068ff35b0394135666262d04ca26\"", "Last-Modified": "Thu, 28 Dec 2017 04:56:43 GMT", "X-OAuth-Scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user", "X-Accepted-OAuth-Scopes": "repo", "X-GitHub-Media-Type": "github.v3; param=drax-preview; format=json", "Access-Control-Expose-Headers": "ETag, Link, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "Access-Control-Allow-Origin": "*", "Content-Security-Policy": "default-src 'none'", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", "X-Content-Type-Options": "nosniff", "X-Frame-Options": "deny", "X-XSS-Protection": "1; mode=block", "X-Runtime-rack": "0.043314", "Content-Encoding": "gzip", "X-GitHub-Request-Id": "A918:04CE:2DACDD:611CE0:5A4AA43F"}, "status": {"code": 200, "message": "OK"}, "url": "https://api.github.com/repos/sigmavirus24/github3.py"}, "recorded_at": "2018-01-01T21:12:31"}, {"request": {"body": {"encoding": "utf-8", "string": ""}, "headers": {"User-Agent": "github3.py/1.0.0a4", "Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "Connection": "keep-alive", "Accept-Charset": "utf-8", "Content-Type": "application/json", "Authorization": "token <AUTH_TOKEN>"}, "method": "GET", "uri": "https://api.github.com/repos/sigmavirus24/github3.py/collaborators?per_page=100"}, "response": {"body": {"encoding": "utf-8", "base64_string": "H4sIAAAAAAAAA73VXW/aMBQG4P/ia9SEAC0gTfsVu5omZIKbeM2X/JGqi/jvO07czDYlneOoVyA475uDyQM/O1TUGa3QEXHSEszRCtELOiZx/Lg9rBBuscDsJFkBE7kQDT9G0fAi3zxkVOTyLDlhaV0JUomHtC4jGQ3p7+23LdRlTJeoXgQvOGUN1T1DGMp4NO6Si7Jwrj5ctB8ex57roqhfIeluer88GjOw0vCcVpl3HjJdVIucwCHB6lf1gSkXPov0812kHk70oho4nDkjF49ldAJWea1giy5ipKn7KnnmKaONoHXls5SVg56aZbiif7BvD+TUPaXW8bl8Pw85uCcrr8McAl3UMNri9E0dASMpoS0cp3eZk4Qu8dYQuIt/wFetDpcKcsKXUvkRTJIVaggrKefqsNGxQ/q9Z1xw9abk+TgoCyClQtfrykBIsxK3lEmeKDs9xW2838SzKfbpEIr2Rp+AtIf9WBrZAJy3LUFEzbowqGbTglytWhP7LLRmmzddMzwDsBlfiLG9kfUzMIn5HeyHmrX0zzHXZfa7eNGMd8km2T9NM07u/qMO6QDG4y7TgMcxL7pDaj5aKx/CVRcFQdUdyxF9LwzFqXt8WeqYP0gdXIbiuMVCCP//L5VwnArywvFZS3zcH3aH9bTE+K7EIR0g0dpnWqM16iXyX3K+ypuOEJlGWZBOo2c5oWZpqFKjy1eqEfXXaoSXEWtt8+VqqeAlKbEQaS6rTMt92uz26ziZpru+S1fHA+zebDXt92bcy7Cdnu/4w54Qy05hkGenaznTbnGoa6fP17YT9/ftFCxj/Garr3H+6y+0rQ/udxIAAA==", "string": ""}, "headers": {"Server": "GitHub.com", "Date": "Mon, 01 Jan 2018 21:12:31 GMT", "Content-Type": "application/json; charset=utf-8", "Transfer-Encoding": "chunked", "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4996", "X-RateLimit-Reset": "1514844517", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", "ETag": "W/\"bfbd076a8fe1b22274427e648ee8ab8e\"", "X-OAuth-Scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user", "X-Accepted-OAuth-Scopes": "", "X-GitHub-Media-Type": "github.v3; param=full; format=json", "Access-Control-Expose-Headers": "ETag, Link, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "Access-Control-Allow-Origin": "*", "Content-Security-Policy": "default-src 'none'", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", "X-Content-Type-Options": "nosniff", "X-Frame-Options": "deny", "X-XSS-Protection": "1; mode=block", "X-Runtime-rack": "0.046608", "Content-Encoding": "gzip", "X-GitHub-Request-Id": "A918:04CE:2DACE1:611CE8:5A4AA43F"}, "status": {"code": 200, "message": "OK"}, "url": "https://api.github.com/repos/sigmavirus24/github3.py/collaborators?per_page=100"}, "recorded_at": "2018-01-01T21:12:31"}], "recorded_with": "betamax/0.8.0"}
{"http_interactions": [{"request": {"body": {"encoding": "utf-8", "string": ""}, "headers": {"User-Agent": "github3.py/1.0.2", "Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "Connection": "keep-alive", "Accept-Charset": "utf-8", "Content-Type": "application/json", "Authorization": "token <AUTH_TOKEN>"}, "method": "GET", "uri": "https://api.github.com/repos/sigmavirus24/github3.py"}, "response": {"body": {"encoding": "utf-8", "base64_string": "H4sIAAAAAAAAA62YTW/jNhCG/4qgyx7qWP6sXQHFtoeim1MXbXrpxaAl2mIjiSpJ2XWE/Pe+Q8qyZGDtJOwlsWnOw+FwZjjDJhRpGM9X08lqOh2FJSt4GId7YbJ6Ox9Xp3AU7uo837Q/aLEv2EGoWs8W0WCWPJZchXET5nIvSjD6U0GhZWaLyXo+GYXswAxTm1rlmJcZU+k4itygno8dttZcJbI0vDTjRBZRHTnpz4cfF8DtVQshboiBK1glWo4TBkxHVxplpsivdHBLW5GryTuZ5/IIyrXW9xaKOkkypaWIcv9BCiSbSJqMw3jY0isZQmjzfqWsVIMT1GYjUuJonIji6bsVa+WgFjnAaxMpXkkLrLc6UaIyQpbvV3AgDZpUe1aKF/YxGqQ1IKTa+1WxUpDmB/ji+8WdWBNVShxYciLTKJ5wcYCxP4i8kgfRnCqK2z/hFGR6YfiGpQXF4Y7lmr+OQru8wSQ7MELYvdX7h3Ge8u5UseAXMQoePxUBC3KxVUydgp1UgUDYKpYYuGtwRCoJfn00X+rtJx38/ssfT8HPXx8xBTKIb9hUwKwBK9OAq70sZSGS4MhO4+AxOEr1HMgy+HoyGf7NxqtRMB8v6M9yZEXm4++xX6z53G3sZiKwZzmI7eHuiHTniG8iEO0AQKVnfvLikHwT4W8bngkyB9tKxYy8l4NuKzgANVH/K7mm4azwUtwCAMqk9LOkBQAktK75myLl9sYtR0fncCzrYusy6FuC8DbaEaAr07g2Ss69LNhBmuic5BFaZZL5Yc+MJnKf7GmzvZeqJA/MNpdbLw7u3chCmkhnzF1rZuOrHVGJMYAqvvNWlRgd1CjP87ZqEqRD4k41OHovPc+MqGktmrNyX7O9H7WD4NTp5t+zl7s10e3YuVCApIJPiW3tn+QuHNLUlSKIdz+TXjAXqK1vbldNdwzQq5OsCYpC3CszbhNbxMDt/wcs+ek1mr7fr4ruq0uMJrrkZJf0W7qPddusf9azv0bbXXi5xJkRNd9VzGSUubBUxRT3UbpFRM2WoXYbj8dNxpmt0gvUSH4R7AhAMZVkKEJ99GzODFQ9BTO2+N+RmimagVyy1Mu2HQRAd4w+ujpC//wr9LVeClpAn1iInGsjS88T6ih9dimN2InkLQ3Q7XAbgJrPWpQJH7E8H8FrjUgE/Bh1O50iCk7uZyFHwDbwrOAan5zDpb2srrhjNJFrXFNe5fLknYV6GApixdEspRtm0OTMJtPZw2T+MJ0/TX+Il+t4Of8Lc+oqHcxZP0wWD5PV03QWLxbxbElzqlpnPYybsn6aLuPJOp6uaArSauvX+IR3kG+8QfT6FHrZgKDW2UXwp4tY/I1HmlYsyeGgV5H09jUP13fdfVGomsmCV6g9es89Tm4+hqFTPGikMtFjIWlb4gXzltP1Ei9FvRojkXWJ01itZqPwyAzKYdzm/cFzbYJFXMNICzO9cZEfxkbV1PdipFLyb54Y3R+7ZJvexKN4FpeOmSSpgOpGXLfY6jBbr5CfhVKyfdkqkR66NItXqrbxlhUvW5069dcINpHwUmPnDfWO2IN95sEW2pe339qvukr/RU8Yxg5vu136iBbf9Z6xVaS3CmwG/tlkrQVTvmN1bjauF8ByKZqYXFbks1wVsBk925A27TuCsx7589lqlP7cZ6yNBCKPG/1PzeCV9o45T3O/2CHsl4qb4S+K0y03lCm5od7/bB+7o34R15p8Pn/9D+gxqKTAFAAA", "string": ""}, "headers": {"Server": "GitHub.com", "Date": "Sun, 08 Apr 2018 15:28:18 GMT", "Content-Type": "application/json; charset=utf-8", "Transfer-Encoding": "chunked", "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4931", "X-RateLimit-Reset": "1523203376", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", "ETag": "W/\"84bf73322e8e02484d9dd6a5b2215bac\"", "Last-Modified": "Sat, 07 Apr 2018 12:44:25 GMT", "X-OAuth-Scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user", "X-Accepted-OAuth-Scopes": "repo", "X-GitHub-Media-Type": "github.v3; param=full; format=json", "Access-Control-Expose-Headers": "ETag, Link, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "Access-Control-Allow-Origin": "*", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", "X-Frame-Options": "deny", "X-Content-Type-Options": "nosniff", "X-XSS-Protection": "1; mode=block", "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", "X-Runtime-rack": "0.077181", "Content-Encoding": "gzip", "X-GitHub-Request-Id": "A572:10EE:24BA85:624438:5ACA3512"}, "status": {"code": 200, "message": "OK"}, "url": "https://api.github.com/repos/sigmavirus24/github3.py"}, "recorded_at": "2018-04-08T15:28:18"}, {"request": {"body": {"encoding": "utf-8", "string": ""}, "headers": {"User-Agent": "github3.py/1.0.2", "Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "Connection": "keep-alive", "Accept-Charset": "utf-8", "Content-Type": "application/json", "Authorization": "token <AUTH_TOKEN>"}, "method": "GET", "uri": "https://api.github.com/repos/sigmav 8000 irus24/github3.py/collaborators?affiliation=all&per_page=100"}, "response": {"body": {"encoding": "utf-8", "base64_string": "H4sIAAAAAAAAA62W226jMBRF/8XPUc2QtE0ijeYr5mk0ihziglvAyBeqDsq/9xhcxk4bUmOeEsHZi50TVsifDpU8ZzXaI0lbSiRaIXZC+zRJHja7FSItUUQctChholCqkXuMh4NyfZczVeijllRkvFa0VncZr7DGQ/pX+3MDuFxYiOEiOHABa5jlDGGASTx2KVRVXlx9uGg/PI498bLkr5C8bHodjscMVBreszoPzkOmw1wVFJYE1c/mAzOpQor08x02Lwd2MgQJOxf0FFDGJqDKaw0tOixow3uUPspMsEYxXoeU8nLA4SInNftHQjmQM/eUqRNy+X4ecnBP1kHLHAIdbgRrSfZmViBoRlkL6wyGXSSBpd4aCnfxb/iqzXKZogdyqow/Smi6Qg0VFZPSLBvtO2TPPZFSmpNaFuOgLkEpEzqfV46ELK9Iy4SWqXGnV3GTbNfJbBX7dIyKfqMbQvrDYVo62Qg5P1OiFHVxcaK6pAV19bCu7LOkdWnB6rrhGQK78YU09ht5PwOTMn8I+6XN1vTbMvMqfy5frMb36TrdPk5rnF59og7pCI3HLtMCj2NB6g6p+dJ6+RhdLShKVMtYTtEPYKyclhOqpY2FC2mDy6g4tvi+hMs8UakkmaIvkhytiA/b3f3ux7SIyVURh3SEiF6faRm90SAh/yfnS/mJESOmA4uS0+EsJ6gLjZXUYYWK6kTDZXXCywjrtfm+tJNPzhv/g/++A/HLFbCODgAA", "string": ""}, "headers": {"Server": "GitHub.com", "Date": "Sun, 08 Apr 2018 15:28:18 GMT", "Content-Type": "application/json; charset=utf-8", "Transfer-Encoding": "chunked", "Status": "200 OK", "X-RateLimit-Limit": "5000", "X-RateLimit-Remaining": "4930", "X-RateLimit-Reset": "1523203376", "Cache-Control": "private, max-age=60, s-maxage=60", "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", "ETag": "W/\"08be3d42e9c06de25328b5b6721a8eac\"", "X-OAuth-Scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user", "X-Accepted-OAuth-Scopes": "", "X-GitHub-Media-Type": "github.v3; param=full; format=json", "Access-Control-Expose-Headers": "ETag, Link, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "Access-Control-Allow-Origin": "*", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", "X-Frame-Options": "deny", "X-Content-Type-Options": "nosniff", "X-XSS-Protection": "1; mode=block", "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", "X-Runtime-rack": "0.044490", "Content-Encoding": "gzip", "X-GitHub-Request-Id": "A572:10EE:24BA88:624442:5ACA3512"}, "status": {"code": 200, "message": "OK"}, "url": "https://api.github.com/repos/sigmavirus24/github3.py/collaborators?affiliation=all&per_page=100"}, "recorded_at": "2018-04-08T15:28:18"}], "recorded_with": "betamax/0.8.0"}
2 changes: 1 addition & 1 deletion tests/integration/test_repos_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def test_collaborators(self):
repository = self.gh.repository('sigmavirus24', 'github3.py')
assert repository is not None
for collaborator in repository.collaborators():
assert isinstance(collaborator, github3.users.ShortUser)
assert isinstance(collaborator, github3.users.Collaborator)

def test_comments(self):
"""Test the ability to retrieve comments on a repository."""
Expand Down
20 changes: 18 additions & 2 deletions tests/unit/test_repos_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1072,10 +1072,26 @@ def test_collaborators(self):

self.session.get.assert_called_once_with(
url_for('collaborators'),
params={'per_page': 100},
params={'affiliation': 'all', 'per_page': 100},
headers={}
)

def test_collaborators_valid_affiliation(self):
"""Test the iterating over repo collaborators with an affiliation."""
i = self.instance.collaborators(affiliation='direct')
self.get_next(i)

self.session.get.assert_called_once_with(
url_for('collaborators'),
params={'affiliation': 'direct', 'per_page': 100},
headers={}
)

def test_collaborators_invalid_affiliation(self):
"""Test invalid affiliation requests raise ValueError."""
with pytest.raises(ValueError):
self.instance.collaborators(affiliation='invalid')

def test_comments(self):
"""Test the ability to iterate over the comments on a repository."""
i = self.instance.comments()
Expand Down Expand Up @@ -1223,7 +1239,7 @@ def test_hooks(self):
)

def test_imported_issues(self):
"""Verify the request for retreiving imported issues."""
"""Verify the request for retrieving imported issues."""
i = self.instance.imported_issues(since='2015-03-15')
self.get_next(i)

Expand Down
0