Implement GET /users (issue #173)

This commit is contained in:
Vincent Jacques
2013-06-18 17:58:29 +02:00
parent 8e69f693dc
commit f62f384bc6
5 changed files with 61 additions and 1 deletions
+4
View File
@@ -571,6 +571,10 @@ APIs
* PUT: :meth:`github.AuthenticatedUser.AuthenticatedUser.add_to_watched`
* DELETE: :meth:`github.AuthenticatedUser.AuthenticatedUser.remove_from_watched`
* ``/users``
* GET: :meth:`github.MainClass.Github.get_users`
* ``/users/:user``
* GET: :meth:`github.MainClass.Github.get_user`
+18 -1
View File
@@ -99,7 +99,7 @@ class Github(object):
def get_user(self, login=github.GithubObject.NotSet):
"""
:calls: `GET /users/:user <http://developer.github.com/v3/todo>`_
:calls: `GET /users/:user <http://developer.github.com/v3/users/#get-a-single-user>`_ or `GET /user <http://developer.github.com/v3/users/#get-the-authenticated-user>`_
:param login: string
:rtype: :class:`github.NamedUser.NamedUser`
"""
@@ -115,6 +115,23 @@ class Github(object):
)
return github.NamedUser.NamedUser(self.__requester, data, completed=True)
def get_users(self, since=github.GithubObject.NotSet):
"""
:calls: `GET /users <http://developer.github.com/v3/users/#get-all-users>`_
:param since: integer
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser`
"""
assert since is github.GithubObject.NotSet or isinstance(since, (int, long)), since
url_parameters = dict()
if since is not github.GithubObject.NotSet:
url_parameters["since"] = since
return github.PaginatedList.PaginatedList(
github.NamedUser.NamedUser,
self.__requester,
"/users",
url_parameters
)
def get_organization(self, login):
"""
:calls: `GET /orgs/:org <http://developer.github.com/v3/todo>`_
+6
View File
@@ -113,3 +113,9 @@ class Github(Framework.TestCase):
def testStringOfNotSet(self):
self.assertEqual(str(github.GithubObject.NotSet), "NotSet")
def testGetUsers(self):
self.assertListKeyBegin(self.g.get_users(), lambda u: u.login, ["mojombo","defunkt","pjhyett","wycats","ezmobius","ivey","evanphx","vanpelt","wayneeseguin","brynary","kevinclark","technoweenie","macournoyer","takeo","Caged","topfunky","anotherjesse","roland","lukas","fanvsfan","tomtt","railsjitsu","nitay","kevwil","KirinDave","jamesgolick","atmos","errfree","mojodna","bmizerany","jnewland","joshknowles","hornbeck","jwhitmire","elbowdonkey","reinh","timocratic","bs","rsanheim","schacon","uggedal","bruce","sam","mmower","abhay","rabble","benburkert","indirect","fearoffish","ry","engineyard","jsierles","tweibley","peimei","brixen","tmornini","outerim","daksis","sr","lifo","rsl","imownbey","dylanegan","jm","willcodeforfoo","jvantuyl","BrianTheCoder","freeformz","hassox","automatthew","queso","lancecarlson","drnic","lukesutton","danwrong","hcatlin","jfrost","mattetti","ctennis","lawrencepit","marcjeanson","grempe","peterc","ministrycentered","afarnham","up_the_irons","evilchelu","heavysixer","brosner","danielmorrison","danielharan","kvnsmth","collectiveidea","canadaduane","nate","dstrelau","sunny","dkubb","jnicklas","richcollins","simonjefford"])
def testGetUsersSince(self):
self.assertListKeyBegin(self.g.get_users(since=1000), lambda u: u.login, ["sbecker"])
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long