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:
Steve Kowalik
2019-10-31 20:56:46 +11:00
committed by GitHub
parent 6ad592b1b6
commit 077c80ba2d
5 changed files with 52 additions and 6 deletions
+3 -3
View File
@@ -45,7 +45,7 @@ import github.GithubObject
class Membership(github.GithubObject.CompletableGithubObject):
"""
This class represents Organizations. The reference can be found here http://developer.github.com/v3/orgs/
This class represents Membership of an organization. The reference can be found here http://developer.github.com/v3/orgs/
"""
def __repr__(self):
@@ -94,7 +94,7 @@ class Membership(github.GithubObject.CompletableGithubObject):
@property
def user(self):
"""
:type: :class:`github.AuthenticatedUser.AuthenticatedUser`
:type: :class:`github.NamedUser.NamedUser`
"""
self._completeIfNotSet(self._user)
return self._user.value
@@ -119,4 +119,4 @@ class Membership(github.GithubObject.CompletableGithubObject):
if "organization" in attributes: # pragma no branch
self._organization = self._makeClassAttribute(github.Organization.Organization, attributes["organization"])
if "user" in attributes: # pragma no branch
self._user = self._makeClassAttribute(github.AuthenticatedUser.AuthenticatedUser, attributes["user"])
self._user = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["user"])