get repos missing params for authenticated users (#915)

first commit to fix issue #435
This commit is contained in:
Riccardo Pittau
2018-10-04 15:55:11 +08:00
committed by Wan Liuyang
parent e18b107883
commit c411196f24
3 changed files with 12 additions and 4 deletions
+10 -2
View File
@@ -899,18 +899,26 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
)
return github.Repository.Repository(self._requester, headers, data, completed=True)
def get_repos(self, type=github.GithubObject.NotSet, sort=github.GithubObject.NotSet, direction=github.GithubObject.NotSet):
def get_repos(self, visibility=github.GithubObject.NotSet, affiliation=github.GithubObject.NotSet, type=github.GithubObject.NotSet, sort=github.GithubObject.NotSet, direction=github.GithubObject.NotSet):
"""
:calls: `GET /user/repos <http://developer.github.com/v3/repos>`_
:calls: `GET /user/repos <http://developer.github.com/v3/repos>`
:param visibility: string
:param affiliation: string
:param type: string
:param sort: string
:param direction: string
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository`
"""
assert visibility is github.GithubObject.NotSet or isinstance(visibility, (str, unicode)), visibility
assert affiliation is github.GithubObject.NotSet or isinstance(affiliation, (str, unicode)), affiliation
assert type is github.GithubObject.NotSet or isinstance(type, (str, unicode)), type
assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort
assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), direction
url_parameters = dict()
if visibility is not github.GithubObject.NotSet:
url_parameters["visibility"] = visibility
if affiliation is not github.GithubObject.NotSet:
url_parameters["affiliation"] = affiliation
if type is not github.GithubObject.NotSet:
url_parameters["type"] = type
if sort is not github.GithubObject.NotSet:
+1 -1
View File
@@ -218,7 +218,7 @@ class AuthenticatedUser(Framework.TestCase):
self.assertListKeyEqual(self.user.get_repos(), lambda r: r.name, ["TestPyGithub", "django", "PyGithub", "developer.github.com", "acme-public-website", "C4Planner", "Hacking", "vincent-jacques.net", "Contests", "Candidates", "Tests", "DrawTurksHead", "DrawSyntax", "QuadProgMm", "Boost.HierarchicalEnum", "ViDE"])
def testGetReposWithArguments(self):
self.assertListKeyEqual(self.user.get_repos("public", "full_name", "desc"), lambda r: r.name, ["ViDE", "QuadProgMm", "PyGithub", "DrawTurksHead", "DrawSyntax", "django", "developer.github.com", "C4Planner", "Boost.HierarchicalEnum", "acme-public-website"])
self.assertListKeyEqual(self.user.get_repos("all", "owner", "public", "full_name", "desc"), lambda r: r.name, ["ViDE", "QuadProgMm", "PyGithub", "DrawTurksHead", "DrawSyntax", "django", "developer.github.com", "C4Planner", "Boost.HierarchicalEnum", "acme-public-website"])
def testCreateFork(self):
repo = self.user.create_fork(self.g.get_user("nvie").get_repo("gitflow"))
@@ -2,7 +2,7 @@ https
GET
api.github.com
None
/user/repos?sort=full_name&direction=desc&type=public
/user/repos?affiliation=owner&visibility=all&sort=full_name&direction=desc&type=public
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
None
200