Skip to content

Commit

Permalink
fix delete review function
Browse files Browse the repository at this point in the history
  • Loading branch information
bagashvilit committed Mar 24, 2021
1 parent 6504caf commit 0cdc771
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 17 deletions.
11 changes: 0 additions & 11 deletions github/PullRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,17 +502,6 @@ def create_review(
self._requester, headers, data, completed=True
)

def delete_pending_review(self, id):
"""
:calls: `POST /repos/:owner/:repo/pulls/:number/reviews/:review_id <https://developer.github.com/v3/pulls/reviews/>`_
:param id: integer
:rtype: None
"""
assert isinstance(id, int), id
headers, data = self._requester.requestJsonAndCheck(
"DELETE", f"{self.url}/reviews{id}"
)

def create_review_request(
self,
reviewers=github.GithubObject.NotSet,
Expand Down
1 change: 0 additions & 1 deletion github/PullRequest.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class PullRequest(CompletableGithubObject):
event: Union[_NotSetType, str] = ...,
comments: Union[_NotSetType, str] = ...,
) -> PullRequestReview: ...
def delete_pending_review(self,id: int) -> None: ...
def create_review_comment(
self, body: str, commit_id: Commit, path: str, position: int
) -> PullRequestComment: ...
Expand Down
9 changes: 9 additions & 0 deletions github/PullRequestReview.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ def dismiss(self, message):
input=post_parameters,
)

def delete(self):
"""
:calls: `POST /repos/:owner/:repo/pulls/:number/reviews/:review_id <https://developer.github.com/v3/pulls/reviews/>`_
:rtype: None
"""
headers, data = self._requester.requestJsonAndCheck(
"DELETE", f"{self.pull_request_url}/reviews/{self.id}"
)

def _initAttributes(self):
self._id = github.GithubObject.NotSet
self._user = github.GithubObject.NotSet
Expand Down
1 change: 1 addition & 0 deletions github/PullRequestReview.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class PullRequestReview(CompletableGithubObject):
@property
def commit_id(self) -> str: ...
def dismiss(self, message: str) -> None: ...
def delete(self) -> None: ...
@property
def html_url(self) -> str: ...
@property
Expand Down
10 changes: 5 additions & 5 deletions tests/PullRequestReview.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ def testDismiss(self):
pr = self.pull.get_review(28482091)
self.assertEqual(pr.state, "DISMISSED")

def testDelete(self):
self.pullreview.delete()
pr = self.pull.get_review(28482091)
self.assertEqual(pr.state, "CHANGES_REQUESTED")

def testAttributes(self):
self.assertEqual(self.pullreview.id, 28482091)
self.assertEqual(self.pullreview.user.login, "jzelinskie")
Expand All @@ -79,8 +84,3 @@ def testAttributes(self):
repr(self.pullreview),
'PullRequestReview(user=NamedUser(login="jzelinskie"), id=28482091)',
)

def testDeleteReview(self):
self.pullreview.delete_pending_review()
review_id = self.pull.get_review(28482091)
self.assertEqual(pr.state, "CHANGES_REQUESTED")
22 changes: 22 additions & 0 deletions tests/ReplayData/PullRequestReview.testDelete.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
https
DELETE
api.github.com
None
/repos/PyGithub/PyGithub/pulls/538/reviews/28482091
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}

200
[('content-length', '1418'), ('x-runtime-rack', '0.166821'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding'), ('x-oauth-scopes', 'admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('x-accepted-oauth-scopes', ''), ('etag', '"f9b71d9dcbbfefb597df3b00efc8cb2a"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('referrer-policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('status', '200 OK'), ('x-ratelimit-remaining', '4545'), ('x-github-media-type', 'github.v3; format=json'), ('access-control-expose-headers', 'ETag, Link, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', 'DDDD:9B6D:C86D83:EADA76:5AB118D3'), ('date', 'Tue, 23 Feb 2018 23:42:09 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1521556163')]
{"id":28482091,"user":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars3.githubusercontent.com/u/343539?v=4","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"body":"","state":"CHANGES_REQUESTED","html_url":"https://github.com/PyGithub/PyGithub/pull/538#pullrequestreview-28482091","pull_request_url":"https://api.github.com/repos/PyGithub/PyGithub/pulls/538","author_association":"OWNER","_links":{"html":{"href":"https://github.com/PyGithub/PyGithub/pull/538#pullrequestreview-28482091"},"pull_request":{"href":"https://api.github.com/repos/PyGithub/PyGithub/pulls/538"}},"submitted_at":"2017-03-22T19:06:59Z","commit_id":"7a0fcb27b7cd6c346fc3f76216ccb6e0f4ca3bcc"}

https
GET
api.github.com
None
/repos/PyGithub/PyGithub/pulls/538/reviews/28482091
{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
None
200
[('content-length', '1418'), ('x-runtime-rack', '0.166821'), ('vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding'), ('x-oauth-scopes', 'admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion'), ('x-xss-protection', '1; mode=block'), ('x-content-type-options', 'nosniff'), ('x-accepted-oauth-scopes', ''), ('etag', '"a687dafdcbb9aeb597df3b00efc8cb2a"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('referrer-policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('status', '200 OK'), ('x-ratelimit-remaining', '4545'), ('x-github-media-type', 'github.v3; format=json'), ('access-control-expose-headers', 'ETag, Link, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('x-github-request-id', 'DDDD:9B6D:C86D83:EADA76:5AB118D3'), ('date', 'Tue, 23 Feb 2018 23:42:19 GMT'), ('access-control-allow-origin', '*'), ('content-security-policy', "default-src 'none'"), ('strict-transport-security', 'max-age=31536000; includeSubdomains; preload'), ('server', 'GitHub.com'), ('x-ratelimit-limit', '5000'), ('x-frame-options', 'deny'), ('content-type', 'application/json; charset=utf-8'), ('x-ratelimit-reset', '1521556163')]
{"id":28482091,"user":{"login":"jzelinskie","id":343539,"avatar_url":"https://avatars3.githubusercontent.com/u/343539?v=4","gravatar_id":"","url":"https://api.github.com/users/jzelinskie","html_url":"https://github.com/jzelinskie","followers_url":"https://api.github.com/users/jzelinskie/followers","following_url":"https://api.github.com/users/jzelinskie/following{/other_user}","gists_url":"https://api.github.com/users/jzelinskie/gists{/gist_id}","starred_url":"https://api.github.com/users/jzelinskie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzelinskie/subscriptions","organizations_url":"https://api.github.com/users/jzelinskie/orgs","repos_url":"https://api.github.com/users/jzelinskie/repos","events_url":"https://api.github.com/users/jzelinskie/events{/privacy}","received_events_url":"https://api.github.com/users/jzelinskie/received_events","type":"User","site_admin":false},"body":"","state":"CHANGES_REQUESTED","html_url":"https://github.com/PyGithub/PyGithub/pull/538#pullrequestreview-28482091","pull_request_url":"https://api.github.com/repos/PyGithub/PyGithub/pulls/538","author_association":"OWNER","_links":{"html":{"href":"https://github.com/PyGithub/PyGithub/pull/538#pullrequestreview-28482091"},"pull_request":{"href":"https://api.github.com/repos/PyGithub/PyGithub/pulls/538"}},"submitted_at":"2017-03-22T19:06:59Z","commit_id":"7a0fcb27b7cd6c346fc3f76216ccb6e0f4ca3bcc"}

0 comments on commit 0cdc771

Please sign in to comment.