From c411196f244b4cfe7520d4fa4ff0dfe60a6c83f0 Mon Sep 17 00:00:00 2001 From: Riccardo Pittau Date: Thu, 4 Oct 2018 09:55:11 +0200 Subject: [PATCH] get repos missing params for authenticated users (#915) first commit to fix issue #435 --- github/AuthenticatedUser.py | 12 ++++++++++-- github/tests/AuthenticatedUser.py | 2 +- .../AuthenticatedUser.testGetReposWithArguments.txt | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/github/AuthenticatedUser.py b/github/AuthenticatedUser.py index c9bcfbd5..e230a0ee 100644 --- a/github/AuthenticatedUser.py +++ b/github/AuthenticatedUser.py @@ -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 `_ + :calls: `GET /user/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: diff --git a/github/tests/AuthenticatedUser.py b/github/tests/AuthenticatedUser.py index a92778f5..c498b16e 100644 --- a/github/tests/AuthenticatedUser.py +++ b/github/tests/AuthenticatedUser.py @@ -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")) diff --git a/github/tests/ReplayData/AuthenticatedUser.testGetReposWithArguments.txt b/github/tests/ReplayData/AuthenticatedUser.testGetReposWithArguments.txt index f3e6afea..e79d0db4 100644 --- a/github/tests/ReplayData/AuthenticatedUser.testGetReposWithArguments.txt +++ b/github/tests/ReplayData/AuthenticatedUser.testGetReposWithArguments.txt @@ -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