Gists with since (#914)

The Github gists api has a since parameter for the various gist searches.  This adds that parameter to Github.get_gists(), NamedUser.get_gists() and Authenticator.get_gists().  Tests and replay data added/updated as needed.

I added a Time module in the tests directory, containing just a UTCtzinfo class, which I felt I needed for one of the tests (and would probably be useful in other since/until tests).  Might not be the best name for the module but it seemed the least invasive thing to do.
This commit is contained in:
Bruce Richardson
2018-10-03 11:51:59 +08:00
committed by Wan Liuyang
parent a18eeb3a05
commit e18b107883
10 changed files with 107 additions and 8 deletions
+10 -2
View File
@@ -17,6 +17,7 @@
# Copyright 2018 Wan Liuyang <tsfdye@gmail.com> #
# Copyright 2018 namc <namratachaudhary@users.noreply.github.com> #
# Copyright 2018 sfdye <tsfdye@gmail.com> #
# Copyright 2018 itsbruce <it.is.bruce@gmail.com> #
# #
# This file is part of PyGithub. #
# http://pygithub.readthedocs.io/ #
@@ -36,6 +37,8 @@
# #
################################################################################
import datetime
import github.GithubObject
import github.PaginatedList
@@ -402,16 +405,21 @@ class NamedUser(github.GithubObject.CompletableGithubObject):
None
)
def get_gists(self):
def get_gists(self, since=github.GithubObject.NotSet):
"""
:calls: `GET /users/:user/gists <http://developer.github.com/v3/gists>`_
:param since: datetime.datetime format YYYY-MM-DDTHH:MM:SSZ
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Gist.Gist`
"""
assert since is github.GithubObject.NotSet or isinstance(since, datetime.datetime), since
url_parameters = dict()
if since is not github.GithubObject.NotSet:
url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ")
return github.PaginatedList.PaginatedList(
github.Gist.Gist,
self._requester,
self.url + "/gists",
None
url_parameters
)
def get_keys(self):