mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-01 19:31:10 +00:00
Re-work PullRequest reviewer request (#765)
Add create_review_request() and delete_review_request() methods to PullRequest, as well as renaming get_reviewer_requests() to get_review_requests() and cleaning up its return value to firstly respect teams, and secondly to cut out the middleman of PullRequestReviewerRequests, which has been removed. Fixes #597
This commit is contained in:
committed by
Wan Liuyang
parent
1f23c06a4d
commit
e2e29918ea
@@ -70,7 +70,6 @@ from Organization import *
|
||||
from PullRequest import *
|
||||
from PullRequestComment import *
|
||||
from PullRequestReview import *
|
||||
from PullRequestReviewerRequests import *
|
||||
from PullRequestFile import *
|
||||
from RateLimiting import *
|
||||
from Repository import *
|
||||
|
||||
@@ -98,6 +98,16 @@ class PullRequest(Framework.TestCase):
|
||||
comment = self.pull.get_issue_comment(8387331)
|
||||
self.assertEqual(comment.body, "Issue comment created by PyGithub")
|
||||
|
||||
def testReviewRequests(self):
|
||||
self.pull.create_review_request(reviewers="sfdye", team_reviewers="pygithub-owners")
|
||||
review_requests = self.pull.get_review_requests()
|
||||
self.assertListKeyEqual(review_requests[0], lambda c: c.login, ["sfdye"])
|
||||
self.assertListKeyEqual(review_requests[1], lambda c: c.slug, ["pygithub-owners"])
|
||||
self.pull.delete_review_request(reviewers="sfdye")
|
||||
review_requests = self.pull.get_review_requests()
|
||||
self.assertEqual(list(review_requests[0]), [])
|
||||
self.assertListKeyEqual(review_requests[1], lambda c: c.slug, ["pygithub-owners"])
|
||||
|
||||
def testEditWithoutArguments(self):
|
||||
self.pull.edit()
|
||||
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
############################ Copyrights and license ############################
|
||||
# #
|
||||
# Copyright 2017 Aaron Levine <allevin@sandia.gov> #
|
||||
# Copyright 2017 Simon <spam@esemi.ru> #
|
||||
# Copyright 2018 sfdye <tsfdye@gmail.com> #
|
||||
# #
|
||||
# This file is part of PyGithub. #
|
||||
# http://pygithub.readthedocs.io/ #
|
||||
# #
|
||||
# PyGithub is free software: you can redistribute it and/or modify it under #
|
||||
# the terms of the GNU Lesser General Public License as published by the Free #
|
||||
# Software Foundation, either version 3 of the License, or (at your option) #
|
||||
# any later version. #
|
||||
# #
|
||||
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
|
||||
# details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU Lesser General Public License #
|
||||
# along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
|
||||
# #
|
||||
################################################################################
|
||||
|
||||
import Framework
|
||||
|
||||
|
||||
class PullRequestReviewerRequests(Framework.TestCase):
|
||||
def setUp(self):
|
||||
Framework.TestCase.setUp(self)
|
||||
self.repo = self.g.get_repo("PyGithub/PyGithub")
|
||||
self.pull = self.repo.get_pull(538)
|
||||
|
||||
self.pullreviewerrequests = self.pull.get_reviewer_requests()
|
||||
self.pullreviewerrequest = self.pullreviewerrequests[0]
|
||||
|
||||
def testAttributes(self):
|
||||
|
||||
self.assertEqual(self.pullreviewerrequest.id, 2930472)
|
||||
self.assertEqual(self.pullreviewerrequest.login, "jayfk")
|
||||
|
||||
# test __repr__() based on this attributes
|
||||
self.assertEqual(self.pullreviewerrequest.__repr__(), 'PullRequestReviewerRequest(login="jayfk", id=2930472)')
|
||||
@@ -0,0 +1,66 @@
|
||||
https
|
||||
POST
|
||||
api.github.com
|
||||
None
|
||||
/repos/jacquev6/PyGithub/pulls/31/requested_reviewers
|
||||
{'Authorization': 'Basic login_and_password_removed', 'Content-Type': 'application/json', 'User-Agent': 'PyGithub/Python'}
|
||||
{"reviewers":"sfdye","team_reviewers":"pygithub-owners"}
|
||||
201
|
||||
''
|
||||
|
||||
|
||||
https
|
||||
GET
|
||||
api.github.com
|
||||
None
|
||||
/repos/jacquev6/PyGithub/pulls/31/requested_reviewers
|
||||
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
None
|
||||
200
|
||||
[('status', '200 OK'), ('x-ratelimit-remaining', '4985'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('x-ratelimit-limit', '5000'), ('vary', 'Accept, Authorization, Cookie'), ('content-length', '1153'), ('server', 'nginx'), ('last-modified', 'Sat, 03 Nov 2012 08:19:40 GMT'), ('connection', 'keep-alive'), ('etag', '"1ec7d9f2ebb27db7dc002f1382d23975"'), ('cache-control', 'private, s-maxage=60, max-age=60'), ('date', 'Sat, 03 Nov 2012 08:19:46 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
{"users":[{"login":"sfdye","id":343369,"avatar_url":"https://avatars2.githubusercontent.com/u/343369?v=4","gravatar_id":"","url":"https://api.github.com/users/sfdye","html_url":"https://github.com/sfdye","followers_url":"https://api.github.com/users/sfdye/followers","following_url":"https://api.github.com/users/sfdye/following{/other_user}","gists_url":"https://api.github.com/users/sfdye/gists{/gist_id}","starred_url":"https://api.github.com/users/sfdye/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sfdye/subscriptions","organizations_url":"https://api.github.com/users/sfdye/orgs","repos_url":"https://api.github.com/users/sfdye/repos","events_url":"https://api.github.com/users/sfdye/events{/privacy}","received_events_url":"https://api.github.com/users/sfdye/received_events","type":"User","site_admin":false}],"teams":[{"name":"pygithub-owners","id":585225,"slug":"pygithub-owners","description":"","privacy":"closed","url":"https://api.github.com/teams/585225","members_url":"https://api.github.com/teams/585225/members{/member}","repositories_url":"https://api.github.com/teams/585225/repos","permission":"pull"}]}
|
||||
|
||||
https
|
||||
GET
|
||||
api.github.com
|
||||
None
|
||||
/repos/jacquev6/PyGithub/pulls/31/requested_reviewers
|
||||
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
None
|
||||
200
|
||||
[('status', '200 OK'), ('x-ratelimit-remaining', '4985'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('x-ratelimit-limit', '5000'), ('vary', 'Accept, Authorization, Cookie'), ('content-length', '1153'), ('server', 'nginx'), ('last-modified', 'Sat, 03 Nov 2012 08:19:40 GMT'), ('connection', 'keep-alive'), ('etag', '"1ec7d9f2ebb27db7dc002f1382d23975"'), ('cache-control', 'private, s-maxage=60, max-age=60'), ('date', 'Sat, 03 Nov 2012 08:19:46 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
{"users":[{"login":"sfdye","id":343369,"avatar_url":"https://avatars2.githubusercontent.com/u/343369?v=4","gravatar_id":"","url":"https://api.github.com/users/sfdye","html_url":"https://github.com/sfdye","followers_url":"https://api.github.com/users/sfdye/followers","following_url":"https://api.github.com/users/sfdye/following{/other_user}","gists_url":"https://api.github.com/users/sfdye/gists{/gist_id}","starred_url":"https://api.github.com/users/sfdye/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sfdye/subscriptions","organizations_url":"https://api.github.com/users/sfdye/orgs","repos_url":"https://api.github.com/users/sfdye/repos","events_url":"https://api.github.com/users/sfdye/events{/privacy}","received_events_url":"https://api.github.com/users/sfdye/received_events","type":"User","site_admin":false}],"teams":[{"name":"pygithub-owners","id":585225,"slug":"pygithub-owners","description":"","privacy":"closed","url":"https://api.github.com/teams/585225","members_url":"https://api.github.com/teams/585225/members{/member}","repositories_url":"https://api.github.com/teams/585225/repos","permission":"pull"}]}
|
||||
|
||||
https
|
||||
DELETE
|
||||
api.github.com
|
||||
None
|
||||
/repos/jacquev6/PyGithub/pulls/31/requested_reviewers
|
||||
{'Authorization': 'Basic login_and_password_removed', 'Content-Type': 'application/json', 'User-Agent': 'PyGithub/Python'}
|
||||
{"reviewers":"sfdye"}
|
||||
204
|
||||
''
|
||||
|
||||
|
||||
https
|
||||
GET
|
||||
api.github.com
|
||||
None
|
||||
/repos/jacquev6/PyGithub/pulls/31/requested_reviewers
|
||||
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
None
|
||||
200
|
||||
[('status', '200 OK'), ('x-ratelimit-remaining', '4985'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('x-ratelimit-limit', '5000'), ('vary', 'Accept, Authorization, Cookie'), ('content-length', '318'), ('server', 'nginx'), ('last-modified', 'Sat, 03 Nov 2012 08:19:40 GMT'), ('connection', 'keep-alive'), ('etag', '"1ec7d9f2ebb27db7dc002f1382d23975"'), ('cache-control', 'private, s-maxage=60, max-age=60'), ('date', 'Sat, 03 Nov 2012 08:19:46 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
{"users":[],"teams":[{"name":"pygithub-owners","id":585225,"slug":"pygithub-owners","description":"","privacy":"closed","url":"https://api.github.com/teams/585225","members_url":"https://api.github.com/teams/585225/members{/member}","repositories_url":"https://api.github.com/teams/585225/repos","permission":"pull"}]}
|
||||
|
||||
https
|
||||
GET
|
||||
api.github.com
|
||||
None
|
||||
/repos/jacquev6/PyGithub/pulls/31/requested_reviewers
|
||||
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
None
|
||||
200
|
||||
[('status', '200 OK'), ('x-ratelimit-remaining', '4985'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('x-ratelimit-limit', '5000'), ('vary', 'Accept, Authorization, Cookie'), ('content-length', '318'), ('server', 'nginx'), ('last-modified', 'Sat, 03 Nov 2012 08:19:40 GMT'), ('connection', 'keep-alive'), ('etag', '"1ec7d9f2ebb27db7dc002f1382d23975"'), ('cache-control', 'private, s-maxage=60, max-age=60'), ('date', 'Sat, 03 Nov 2012 08:19:46 GMT'), ('content-type', 'application/json; charset=utf-8')]
|
||||
{"users":[],"teams":[{"name":"pygithub-owners","id":585225,"slug":"pygithub-owners","description":"","privacy":"closed","url":"https://api.github.com/teams/585225","members_url":"https://api.github.com/teams/585225/members{/member}","repositories_url":"https://api.github.com/teams/585225/repos","permission":"pull"}]}
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user