mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 10:51:14 +00:00
Add support for deleting reactions (#1708)
* Delete comment reactions * Add test case * update ignore-word-list * Delete issue reactions * Delete issue comment reactions * Delete pull request comment reactions * check status
This commit is contained in:
@@ -22,5 +22,5 @@ repos:
|
||||
- id: codespell
|
||||
exclude: tests/
|
||||
args:
|
||||
- --ignore-words-list="bloaded,nto,pullrequest,pullrequests,thi,tim,wan,Wan"
|
||||
- --ignore-words-list="bloaded,nto,pullrequest,pullrequests,thi,tim,wan,Wan,chang,Chang"
|
||||
- --quiet-level=2
|
||||
|
||||
+17
-1
@@ -9,10 +9,11 @@
|
||||
# Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net> #
|
||||
# Copyright 2016 Jannis Gebauer <ja.geb@me.com> #
|
||||
# Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com> #
|
||||
# Copyright 2017 Nicolas Agustín Torres <nicolastrres@gmail.com> #
|
||||
# Copyright 2017 Nicolas Agustín Torres <nicolastrres@gmail.com> #
|
||||
# Copyright 2018 Wan Liuyang <tsfdye@gmail.com> #
|
||||
# Copyright 2018 per1234 <accounts@perglass.com> #
|
||||
# Copyright 2018 sfdye <tsfdye@gmail.com> #
|
||||
# Copyright 2020 Huan-Cheng Chang <changhc84@gmail.com> #
|
||||
# #
|
||||
# This file is part of PyGithub. #
|
||||
# http://pygithub.readthedocs.io/ #
|
||||
@@ -189,6 +190,21 @@ class CommitComment(github.GithubObject.CompletableGithubObject):
|
||||
)
|
||||
return github.Reaction.Reaction(self._requester, headers, data, completed=True)
|
||||
|
||||
def delete_reaction(self, reaction_id):
|
||||
"""
|
||||
:calls: `DELETE /repos/:owner/:repo/comments/:comment_id/reactions/:reaction_id
|
||||
<https://developer.github.com/v3/reactions/#delete-a-commit-comment-reaction>`_
|
||||
:param reaction_id: integer
|
||||
:rtype: bool
|
||||
"""
|
||||
assert isinstance(reaction_id, int), reaction_id
|
||||
status, _, _ = self._requester.requestJson(
|
||||
"DELETE",
|
||||
self.url + "/reactions/" + str(reaction_id),
|
||||
headers={"Accept": Consts.mediaTypeReactionsPreview},
|
||||
)
|
||||
return status == 204
|
||||
|
||||
def _initAttributes(self):
|
||||
self._body = github.GithubObject.NotSet
|
||||
self._commit_id = github.GithubObject.NotSet
|
||||
|
||||
@@ -18,6 +18,7 @@ class CommitComment(CompletableGithubObject):
|
||||
@property
|
||||
def created_at(self) -> datetime: ...
|
||||
def delete(self) -> None: ...
|
||||
def delete_reaction(self, reaction_id: int) -> bool: ...
|
||||
def edit(self, body: str) -> None: ...
|
||||
def get_reactions(self) -> PaginatedList[Reaction]: ...
|
||||
@property
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
# Copyright 2018 per1234 <accounts@perglass.com> #
|
||||
# Copyright 2018 sfdye <tsfdye@gmail.com> #
|
||||
# Copyright 2019 Nick Campbell <nicholas.j.campbell@gmail.com> #
|
||||
# Copyright 2020 Huan-Cheng Chang <changhc84@gmail.com> #
|
||||
# #
|
||||
# This file is part of PyGithub. #
|
||||
# http://pygithub.readthedocs.io/ #
|
||||
@@ -585,6 +586,20 @@ class Issue(github.GithubObject.CompletableGithubObject):
|
||||
)
|
||||
return github.Reaction.Reaction(self._requester, headers, data, completed=True)
|
||||
|
||||
def delete_reaction(self, reaction_id):
|
||||
"""
|
||||
:calls: `DELETE /repos/:owner/:repo/issues/:issue_number/reactions/:reaction_id <https://developer.github.com/v3/reactions/#delete-an-issue-reaction>`_
|
||||
:param reaction_id: integer
|
||||
:rtype: bool
|
||||
"""
|
||||
assert isinstance(reaction_id, int), reaction_id
|
||||
status, _, _ = self._requester.requestJson(
|
||||
"DELETE",
|
||||
self.url + "/reactions/" + str(reaction_id),
|
||||
headers={"Accept": Consts.mediaTypeReactionsPreview},
|
||||
)
|
||||
return status == 204
|
||||
|
||||
def get_timeline(self):
|
||||
"""
|
||||
:calls: `GET /repos/:owner/:repo/issues/:number/timeline <https://developer.github.com/v3/issues/timeline/#list-events-for-an-issue>`_
|
||||
|
||||
@@ -45,6 +45,7 @@ class Issue(CompletableGithubObject):
|
||||
@property
|
||||
def created_at(self) -> datetime: ...
|
||||
def delete_labels(self) -> None: ...
|
||||
def delete_reaction(self, reaction_id: int) -> bool: ...
|
||||
def edit(
|
||||
self,
|
||||
title: Union[str, _NotSetType] = ...,
|
||||
|
||||
+17
-1
@@ -10,10 +10,11 @@
|
||||
# Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net> #
|
||||
# Copyright 2016 Jannis Gebauer <ja.geb@me.com> #
|
||||
# Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com> #
|
||||
# Copyright 2017 Nicolas Agustín Torres <nicolastrres@gmail.com> #
|
||||
# Copyright 2017 Nicolas Agustín Torres <nicolastrres@gmail.com> #
|
||||
# Copyright 2018 Wan Liuyang <tsfdye@gmail.com> #
|
||||
# Copyright 2018 per1234 <accounts@perglass.com> #
|
||||
# Copyright 2018 sfdye <tsfdye@gmail.com> #
|
||||
# Copyright 2020 Huan-Cheng Chang <changhc84@gmail.com> #
|
||||
# #
|
||||
# This file is part of PyGithub. #
|
||||
# http://pygithub.readthedocs.io/ #
|
||||
@@ -166,6 +167,21 @@ class IssueComment(github.GithubObject.CompletableGithubObject):
|
||||
)
|
||||
return github.Reaction.Reaction(self._requester, headers, data, completed=True)
|
||||
|
||||
def delete_reaction(self, reaction_id):
|
||||
"""
|
||||
:calls: `DELETE /repos/:owner/:repo/issues/comments/:comment_id/reactions/:reaction_id
|
||||
<https://developer.github.com/v3/reactions/#delete-an-issue-comment-reaction>`_
|
||||
:param reaction_id: integer
|
||||
:rtype: bool
|
||||
"""
|
||||
assert isinstance(reaction_id, int), reaction_id
|
||||
status, _, _ = self._requester.requestJson(
|
||||
"DELETE",
|
||||
self.url + "/reactions/" + str(reaction_id),
|
||||
headers={"Accept": Consts.mediaTypeReactionsPreview},
|
||||
)
|
||||
return status == 204
|
||||
|
||||
def _initAttributes(self):
|
||||
self._body = github.GithubObject.NotSet
|
||||
self._created_at = github.GithubObject.NotSet
|
||||
|
||||
@@ -16,6 +16,7 @@ class IssueComment(CompletableGithubObject):
|
||||
@property
|
||||
def created_at(self) -> datetime: ...
|
||||
def delete(self) -> None: ...
|
||||
def delete_reaction(self, reaction_id: int) -> bool: ...
|
||||
def edit(self, body: str) -> None: ...
|
||||
def get_reactions(self) -> PaginatedList[Reaction]: ...
|
||||
@property
|
||||
|
||||
@@ -11,10 +11,11 @@
|
||||
# Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net> #
|
||||
# Copyright 2016 Jannis Gebauer <ja.geb@me.com> #
|
||||
# Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com> #
|
||||
# Copyright 2017 Nicolas Agustín Torres <nicolastrres@gmail.com> #
|
||||
# Copyright 2017 Nicolas Agustín Torres <nicolastrres@gmail.com> #
|
||||
# Copyright 2018 Jess Morgan <979404+JessMorgan@users.noreply.github.com> #
|
||||
# Copyright 2018 per1234 <accounts@perglass.com> #
|
||||
# Copyright 2018 sfdye <tsfdye@gmail.com> #
|
||||
# Copyright 2020 Huan-Cheng Chang <changhc84@gmail.com> #
|
||||
# #
|
||||
# This file is part of PyGithub. #
|
||||
# http://pygithub.readthedocs.io/ #
|
||||
@@ -223,6 +224,21 @@ class PullRequestComment(github.GithubObject.CompletableGithubObject):
|
||||
)
|
||||
return github.Reaction.Reaction(self._requester, headers, data, completed=True)
|
||||
|
||||
def delete_reaction(self, reaction_id):
|
||||
"""
|
||||
:calls: `DELETE /repos/:owner/:repo/pulls/comments/:comment_id/reactions/:reaction_id
|
||||
<https://developer.github.com/v3/reactions/#delete-a-pull-request-comment-reaction>`_
|
||||
:param reaction_id: integer
|
||||
:rtype: bool
|
||||
"""
|
||||
assert isinstance(reaction_id, int), reaction_id
|
||||
status, _, _ = self._requester.requestJson(
|
||||
"DELETE",
|
||||
self.url + "/reactions/" + str(reaction_id),
|
||||
headers={"Accept": Consts.mediaTypeReactionsPreview},
|
||||
)
|
||||
return status == 204
|
||||
|
||||
def _initAttributes(self):
|
||||
self._body = github.GithubObject.NotSet
|
||||
self._commit_id = github.GithubObject.NotSet
|
||||
|
||||
@@ -18,6 +18,7 @@ class PullRequestComment(CompletableGithubObject):
|
||||
@property
|
||||
def created_at(self) -> datetime: ...
|
||||
def delete(self) -> None: ...
|
||||
def delete_reaction(self, reaction_id: int) -> bool: ...
|
||||
@property
|
||||
def diff_hunk(self) -> str: ...
|
||||
def edit(self, body: str) -> None: ...
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
# Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net> #
|
||||
# Copyright 2016 Jannis Gebauer <ja.geb@me.com> #
|
||||
# Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com> #
|
||||
# Copyright 2017 Nicolas Agustín Torres <nicolastrres@gmail.com> #
|
||||
# Copyright 2017 Nicolas Agustín Torres <nicolastrres@gmail.com> #
|
||||
# Copyright 2018 sfdye <tsfdye@gmail.com> #
|
||||
# Copyright 2020 Huan-Cheng Chang <changhc84@gmail.com> #
|
||||
# #
|
||||
# This file is part of PyGithub. #
|
||||
# http://pygithub.readthedocs.io/ #
|
||||
@@ -83,3 +84,6 @@ class CommitComment(Framework.TestCase):
|
||||
|
||||
self.assertEqual(reaction.id, 17283092)
|
||||
self.assertEqual(reaction.content, "hooray")
|
||||
|
||||
def testDeleteReaction(self):
|
||||
self.assertTrue(self.comment.delete_reaction(85737646))
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
# Copyright 2017 Nicolas Agustín Torres <nicolastrres@gmail.com> #
|
||||
# Copyright 2018 sfdye <tsfdye@gmail.com> #
|
||||
# Copyright 2019 Nick Campbell <nicholas.j.campbell@gmail.com> #
|
||||
# Copyright 2020 Huan-Cheng Chang <changhc84@gmail.com> #
|
||||
# #
|
||||
# This file is part of PyGithub. #
|
||||
# http://pygithub.readthedocs.io/ #
|
||||
@@ -263,6 +264,9 @@ class Issue(Framework.TestCase):
|
||||
self.assertEqual(reaction.id, 16917472)
|
||||
self.assertEqual(reaction.content, "hooray")
|
||||
|
||||
def testDeleteReaction(self):
|
||||
self.assertTrue(self.issue.delete_reaction(85740167))
|
||||
|
||||
def testGetTimeline(self):
|
||||
expected_events = {
|
||||
"referenced",
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
# Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net> #
|
||||
# Copyright 2016 Jannis Gebauer <ja.geb@me.com> #
|
||||
# Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com> #
|
||||
# Copyright 2017 Nicolas Agustín Torres <nicolastrres@gmail.com> #
|
||||
# Copyright 2017 Nicolas Agustín Torres <nicolastrres@gmail.com> #
|
||||
# Copyright 2018 sfdye <tsfdye@gmail.com> #
|
||||
# Copyright 2020 Huan-Cheng Chang <changhc84@gmail.com> #
|
||||
# #
|
||||
# This file is part of PyGithub. #
|
||||
# http://pygithub.readthedocs.io/ #
|
||||
@@ -83,3 +84,6 @@ class IssueComment(Framework.TestCase):
|
||||
|
||||
self.assertEqual(reaction.id, 17282654)
|
||||
self.assertEqual(reaction.content, "hooray")
|
||||
|
||||
def testDeleteReaction(self):
|
||||
self.assertTrue(self.comment.delete_reaction(85743754))
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
# Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net> #
|
||||
# Copyright 2016 Jannis Gebauer <ja.geb@me.com> #
|
||||
# Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com> #
|
||||
# Copyright 2017 Nicolas Agustín Torres <nicolastrres@gmail.com> #
|
||||
# Copyright 2017 Nicolas Agustín Torres <nicolastrres@gmail.com> #
|
||||
# Copyright 2018 sfdye <tsfdye@gmail.com> #
|
||||
# Copyright 2020 Huan-Cheng Chang <changhc84@gmail.com> #
|
||||
# #
|
||||
# This file is part of PyGithub. #
|
||||
# http://pygithub.readthedocs.io/ #
|
||||
@@ -89,3 +90,6 @@ class PullRequestComment(Framework.TestCase):
|
||||
|
||||
self.assertEqual(reaction.id, 17283822)
|
||||
self.assertEqual(reaction.content, "hooray")
|
||||
|
||||
def testDeleteReaction(self):
|
||||
self.assertTrue(self.comment.delete_reaction(85750463))
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
https
|
||||
DELETE
|
||||
api.github.com
|
||||
None
|
||||
/repos/jacquev6/PyGithub/comments/1361949/reactions/85737646
|
||||
{'Accept': 'application/vnd.github.squirrel-girl-preview', 'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
None
|
||||
204
|
||||
[('Date', 'Mon, 28 Sep 2020 19:55:51 GMT'), ('Server', 'GitHub.com'), ('Status', '204 No Content'), ('X-OAuth-Scopes', 'public_repo, repo:status, write:discussion'), ('X-Accepted-OAuth-Scopes', ''), ('X-GitHub-Media-Type', 'github.squirrel-girl-preview'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4959'), ('X-RateLimit-Reset', '1601324668'), ('X-RateLimit-Used', '41'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '1; mode=block'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Vary', 'Accept-Encoding, Accept, X-Requested-With, Accept-Encoding'), ('X-GitHub-Request-Id', 'C96E:F313:162969A9:1A634C51:5F723FC7')]
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
https
|
||||
DELETE
|
||||
api.github.com
|
||||
None
|
||||
/repos/jacquev6/PyGithub/issues/28/reactions/85740167
|
||||
{'Accept': 'application/vnd.github.squirrel-girl-preview', 'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
None
|
||||
204
|
||||
[('Date', 'Mon, 28 Sep 2020 20:23:03 GMT'), ('Server', 'GitHub.com'), ('Status', '204 No Content'), ('X-OAuth-Scopes', 'public_repo, repo:status, write:discussion'), ('X-Accepted-OAuth-Scopes', ''), ('X-GitHub-Media-Type', 'github.squirrel-girl-preview'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4955'), ('X-RateLimit-Reset', '1601324668'), ('X-RateLimit-Used', '45'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '1; mode=block'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Vary', 'Accept-Encoding, Accept, X-Requested-With, Accept-Encoding'), ('X-GitHub-Request-Id', 'AE16:FACE:CAD7D10:F1C172A:5F724627')]
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
https
|
||||
DELETE
|
||||
api.github.com
|
||||
None
|
||||
/repos/jacquev6/PyGithub/issues/comments/5808311/reactions/85743754
|
||||
{'Accept': 'application/vnd.github.squirrel-girl-preview', 'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
None
|
||||
204
|
||||
[('Date', 'Mon, 28 Sep 2020 20:58:11 GMT'), ('Server', 'GitHub.com'), ('Status', '204 No Content'), ('X-OAuth-Scopes', 'public_repo, repo:status, write:discussion'), ('X-Accepted-OAuth-Scopes', ''), ('X-GitHub-Media-Type', 'github.squirrel-girl-preview'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4983'), ('X-RateLimit-Reset', '1601330202'), ('X-RateLimit-Used', '17'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '1; mode=block'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Vary', 'Accept-Encoding, Accept, X-Requested-With, Accept-Encoding'), ('X-GitHub-Request-Id', '8F46:7327:16616BD7:1AB22028:5F724E63')]
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
https
|
||||
DELETE
|
||||
api.github.com
|
||||
None
|
||||
/repos/jacquev6/PyGithub/pulls/comments/886298/reactions/85750463
|
||||
{'Accept': 'application/vnd.github.squirrel-girl-preview', 'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
None
|
||||
204
|
||||
[('Date', 'Mon, 28 Sep 2020 22:15:48 GMT'), ('Server', 'GitHub.com'), ('Status', '204 No Content'), ('X-OAuth-Scopes', 'public_repo, repo:status, write:discussion'), ('X-Accepted-OAuth-Scopes', ''), ('X-GitHub-Media-Type', 'github.squirrel-girl-preview'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4991'), ('X-RateLimit-Reset', '1601334930'), ('X-RateLimit-Used', '9'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '1; mode=block'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Vary', 'Accept-Encoding, Accept, X-Requested-With, Accept-Encoding'), ('X-GitHub-Request-Id', '9B34:FACF:17050546:1B72222B:5F726093')]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user