mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-02 11:51:10 +00:00
Repository.get_issues_comments and Repository.get_pulls_comments (issue #126)
This commit is contained in:
@@ -778,6 +778,24 @@ class Repository(github.GithubObject.GithubObject):
|
||||
url_parameters
|
||||
)
|
||||
|
||||
def get_issues_comments(self, sort=github.GithubObject.NotSet, direction=github.GithubObject.NotSet, since=github.GithubObject.NotSet):
|
||||
assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort
|
||||
assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), direction
|
||||
assert since is github.GithubObject.NotSet or isinstance(since, datetime.datetime), since
|
||||
url_parameters = dict()
|
||||
if sort is not github.GithubObject.NotSet:
|
||||
url_parameters["sort"] = sort
|
||||
if direction is not github.GithubObject.NotSet:
|
||||
url_parameters["direction"] = direction
|
||||
if since is not github.GithubObject.NotSet:
|
||||
url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||
return github.PaginatedList.PaginatedList(
|
||||
github.IssueComment.IssueComment,
|
||||
self._requester,
|
||||
self.url + "/issues/comments",
|
||||
url_parameters
|
||||
)
|
||||
|
||||
def get_issues_event(self, id):
|
||||
assert isinstance(id, (int, long)), id
|
||||
headers, data = self._requester.requestAndCheck(
|
||||
@@ -899,6 +917,27 @@ class Repository(github.GithubObject.GithubObject):
|
||||
url_parameters
|
||||
)
|
||||
|
||||
def get_pulls_comments(self, sort=github.GithubObject.NotSet, direction=github.GithubObject.NotSet, since=github.GithubObject.NotSet):
|
||||
return self.get_pulls_review_comments(sort, direction, since)
|
||||
|
||||
def get_pulls_review_comments(self, sort=github.GithubObject.NotSet, direction=github.GithubObject.NotSet, since=github.GithubObject.NotSet):
|
||||
assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort
|
||||
assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), direction
|
||||
assert since is github.GithubObject.NotSet or isinstance(since, datetime.datetime), since
|
||||
url_parameters = dict()
|
||||
if sort is not github.GithubObject.NotSet:
|
||||
url_parameters["sort"] = sort
|
||||
if direction is not github.GithubObject.NotSet:
|
||||
url_parameters["direction"] = direction
|
||||
if since is not github.GithubObject.NotSet:
|
||||
url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||
return github.PaginatedList.PaginatedList(
|
||||
github.IssueComment.IssueComment,
|
||||
self._requester,
|
||||
self.url + "/pulls/comments",
|
||||
url_parameters
|
||||
)
|
||||
|
||||
def get_readme(self, ref=github.GithubObject.NotSet):
|
||||
assert ref is github.GithubObject.NotSet or isinstance(ref, (str, unicode)), ref
|
||||
url_parameters = dict()
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,15 @@
|
||||
https GET api.github.com None /repos/jacquev6/PyGithub/pulls/comments {'Authorization': 'Basic login_and_password_removed'} null
|
||||
200
|
||||
[('status', '200 OK'), ('x-ratelimit-remaining', '4961'), ('x-ratelimit-limit', '5000'), ('x-content-type-options', 'nosniff'), ('vary', 'Accept, Authorization, Cookie'), ('content-length', '1617'), ('server', 'nginx'), ('last-modified', 'Fri, 21 Dec 2012 18:46:45 GMT'), ('connection', 'keep-alive'), ('etag', '"446137bf216c4edc30567fbc3e944b5a"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Tue, 25 Dec 2012 11:55:47 GMT'), ('x-github-media-type', 'github.beta; format=json'), ('content-type', 'application/json; charset=utf-8')]
|
||||
[{"body":"Review comment created for PyGithub","path":"codegen/templates/GithubObject.py","original_commit_id":"8a4f306d4b223682dd19410d4a9150636ebe4206","original_position":5,"updated_at":"2012-09-11T20:06:32Z","url":"https://api.github.com/repos/jacquev6/PyGithub/pulls/comments/1580134","commit_id":"8a4f306d4b223682dd19410d4a9150636ebe4206","created_at":"2012-09-11T20:06:32Z","user":{"type":"User","events_url":"https://api.github.com/users/jacquev6/events{/privacy}","received_events_url":"https://api.github.com/users/jacquev6/received_events","gists_url":"https://api.github.com/users/jacquev6/gists{/gist_id}","followers_url":"https://api.github.com/users/jacquev6/followers","following_url":"https://api.github.com/users/jacquev6/following","organizations_url":"https://api.github.com/users/jacquev6/orgs","url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","starred_url":"https://api.github.com/users/jacquev6/starred{/owner}{/repo}","login":"jacquev6","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","repos_url":"https://api.github.com/users/jacquev6/repos","subscriptions_url":"https://api.github.com/users/jacquev6/subscriptions","id":327146},"position":5,"_links":{"pull_request":{"href":"https://api.github.com/repos/jacquev6/PyGithub/pulls/31"},"html":{"href":"https://github.com/jacquev6/PyGithub/pull/31#discussion_r1580134"},"self":{"href":"https://api.github.com/repos/jacquev6/PyGithub/pulls/comments/1580134"}},"id":1580134}]
|
||||
|
||||
https GET api.github.com None /repos/jacquev6/PyGithub/pulls/comments?sort=created&direction=asc {'Authorization': 'Basic login_and_password_removed'} null
|
||||
200
|
||||
[('status', '200 OK'), ('content-length', '1617'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('x-ratelimit-limit', '5000'), ('vary', 'Accept, Authorization, Cookie'), ('x-ratelimit-remaining', '4960'), ('server', 'nginx'), ('last-modified', 'Fri, 21 Dec 2012 18:46:45 GMT'), ('connection', 'keep-alive'), ('etag', '"446137bf216c4edc30567fbc3e944b5a"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Tue, 25 Dec 2012 11:55:58 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
[{"_links":{"html":{"href":"https://github.com/jacquev6/PyGithub/pull/31#discussion_r1580134"},"self":{"href":"https://api.github.com/repos/jacquev6/PyGithub/pulls/comments/1580134"},"pull_request":{"href":"https://api.github.com/repos/jacquev6/PyGithub/pulls/31"}},"body":"Review comment created for PyGithub","path":"codegen/templates/GithubObject.py","original_commit_id":"8a4f306d4b223682dd19410d4a9150636ebe4206","original_position":5,"updated_at":"2012-09-11T20:06:32Z","url":"https://api.github.com/repos/jacquev6/PyGithub/pulls/comments/1580134","commit_id":"8a4f306d4b223682dd19410d4a9150636ebe4206","created_at":"2012-09-11T20:06:32Z","user":{"type":"User","received_events_url":"https://api.github.com/users/jacquev6/received_events","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","gists_url":"https://api.github.com/users/jacquev6/gists{/gist_id}","followers_url":"https://api.github.com/users/jacquev6/followers","following_url":"https://api.github.com/users/jacquev6/following","organizations_url":"https://api.github.com/users/jacquev6/orgs","starred_url":"https://api.github.com/users/jacquev6/starred{/owner}{/repo}","url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","repos_url":"https://api.github.com/users/jacquev6/repos","login":"jacquev6","events_url":"https://api.github.com/users/jacquev6/events{/privacy}","subscriptions_url":"https://api.github.com/users/jacquev6/subscriptions","id":327146},"position":5,"id":1580134}]
|
||||
|
||||
https GET api.github.com None /repos/jacquev6/PyGithub/pulls/comments?since=2012-05-28T23%3A00%3A00Z {'Authorization': 'Basic login_and_password_removed'} null
|
||||
200
|
||||
[('status', '200 OK'), ('content-length', '1617'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('vary', 'Accept, Authorization, Cookie'), ('x-ratelimit-remaining', '4959'), ('server', 'nginx'), ('last-modified', 'Fri, 21 Dec 2012 18:46:45 GMT'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"446137bf216c4edc30567fbc3e944b5a"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Tue, 25 Dec 2012 11:56:09 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
[{"body":"Review comment created for PyGithub","path":"codegen/templates/GithubObject.py","original_commit_id":"8a4f306d4b223682dd19410d4a9150636ebe4206","original_position":5,"updated_at":"2012-09-11T20:06:32Z","url":"https://api.github.com/repos/jacquev6/PyGithub/pulls/comments/1580134","_links":{"html":{"href":"https://github.com/jacquev6/PyGithub/pull/31#discussion_r1580134"},"pull_request":{"href":"https://api.github.com/repos/jacquev6/PyGithub/pulls/31"},"self":{"href":"https://api.github.com/repos/jacquev6/PyGithub/pulls/comments/1580134"}},"commit_id":"8a4f306d4b223682dd19410d4a9150636ebe4206","created_at":"2012-09-11T20:06:32Z","user":{"type":"User","gists_url":"https://api.github.com/users/jacquev6/gists{/gist_id}","followers_url":"https://api.github.com/users/jacquev6/followers","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","following_url":"https://api.github.com/users/jacquev6/following","organizations_url":"https://api.github.com/users/jacquev6/orgs","url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","events_url":"https://api.github.com/users/jacquev6/events{/privacy}","repos_url":"https://api.github.com/users/jacquev6/repos","login":"jacquev6","received_events_url":"https://api.github.com/users/jacquev6/received_events","subscriptions_url":"https://api.github.com/users/jacquev6/subscriptions","id":327146,"starred_url":"https://api.github.com/users/jacquev6/starred{/owner}{/repo}"},"position":5,"id":1580134}]
|
||||
|
||||
@@ -428,3 +428,13 @@ class Repository(Framework.TestCase):
|
||||
self.assertEqual(exception.status, 409)
|
||||
self.assertEqual(exception.data, {"message": "Merge conflict"})
|
||||
self.assertTrue(raised)
|
||||
|
||||
def testGetIssuesComments(self):
|
||||
self.assertListKeyEqual(self.repo.get_issues_comments()[:40], lambda c: c.id, [5168757, 5181640, 5183010, 5186061, 5226090, 5449237, 5518272, 5547576, 5780183, 5781803, 5820199, 5820912, 5924198, 5965724, 5965812, 5965891, 5966555, 5966633, 5981084, 5981232, 5981409, 5981451, 5991965, 6019700, 6088432, 6293572, 6305625, 6357374, 6357422, 6447481, 6467193, 6467312, 6467642, 6481200, 6481392, 6556134, 6557261, 6568164, 6568181, 6568553])
|
||||
self.assertListKeyEqual(self.repo.get_issues_comments(sort="created", direction="asc")[:40], lambda c: c.id, [5168757, 5181640, 5183010, 5186061, 5226090, 5449237, 5518272, 5547576, 5780183, 5781803, 5820199, 5820912, 5924198, 5965724, 5965812, 5965891, 5966555, 5966633, 5981084, 5981232, 5981409, 5981451, 5991965, 6019700, 6088432, 6293572, 6305625, 6357374, 6357422, 6447481, 6467193, 6467312, 6467642, 6481200, 6481392, 6556134, 6557261, 6568164, 6568181, 6568553])
|
||||
self.assertListKeyEqual(self.repo.get_issues_comments(since=datetime.datetime(2012, 5, 28, 23, 0, 0))[:40], lambda c: c.id, [5981084, 5981232, 5981409, 5981451, 5991965, 6019700, 6088432, 6293572, 6305625, 6357374, 6357422, 6447481, 6467193, 6467312, 6467642, 6481200, 6481392, 6556134, 6557261, 6568164, 6568181, 6568553, 6640187, 6640189, 6641223, 6673380, 6710355, 6727553, 6727659, 6727848, 6728069, 6728241, 6728370, 6886561, 6972414, 6994436, 7060818, 7060993, 7211543, 7407798])
|
||||
|
||||
def testGetPullsComments(self):
|
||||
self.assertListKeyEqual(self.repo.get_pulls_comments(), lambda c: c.id, [1580134])
|
||||
self.assertListKeyEqual(self.repo.get_pulls_comments(sort="created", direction="asc"), lambda c: c.id, [1580134])
|
||||
self.assertListKeyEqual(self.repo.get_pulls_comments(since=datetime.datetime(2012, 5, 28, 23, 0, 0)), lambda c: c.id, [1580134])
|
||||
|
||||
Reference in New Issue
Block a user