mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 19:01:15 +00:00
Correct API for NamedUser.get_organization_membership (#1277)
NamedUser.get_organization_membership() was calling the API method for fetching the currently authenticated user only, which is incorrect. The method was not tested directly, so add tests. Furthermore, Membership had some errors which had slipped through review, so correct them. Sadly, this is an API break, since passing the organization as an int made no sense in this case. Fixes #1276
This commit is contained in:
+6
-3
@@ -626,13 +626,16 @@ class NamedUser(github.GithubObject.CompletableGithubObject):
|
||||
|
||||
def get_organization_membership(self, org):
|
||||
"""
|
||||
:calls: `GET /user/memberships/orgs/:org <https://developer.github.com/v3/orgs/members/#get-your-organization-membership>`_
|
||||
:calls: `GET /orgs/:org/memberships/:username <https://developer.github.com/v3/orgs/members/#get-organization-membership>`_
|
||||
:param org: string or :class:`github.Organization.Organization`
|
||||
:rtype: :class:`github.Membership.Membership`
|
||||
"""
|
||||
assert isinstance(org, int)
|
||||
assert isinstance(org, (str, six.text_type)) or isinstance(org, github.Organization.Organization), org
|
||||
if isinstance(org, github.Organization.Organization):
|
||||
org = org.login
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
"/user/memberships/orgs/" + str(org)
|
||||
"/orgs/" + org + "/memberships/" + self.login
|
||||
)
|
||||
return github.Membership.Membership(self._requester, headers, data, completed=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user