Skip to content

Commit baf7412

Browse files
author
Graham Weldon
committed
Added comment pin/unpin
Signed-off-by: Graham Weldon <graham.weldon@rakuten.com>
1 parent 09104ff commit baf7412

4 files changed

Lines changed: 33 additions & 1 deletion

File tree

atlassian/jira.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,6 +1971,28 @@ def issue_edit_comment(
19711971
params: dict = {"notifyUsers": "true" if notify_users else "false"}
19721972
return self.put(url, data=data, params=params)
19731973

1974+
def issue_pin_comment(self, issue_key: str, comment_id: T_id) -> T_resp_json:
1975+
"""
1976+
Pin a comment on a Jira issue
1977+
:param issue_key: str
1978+
:param comment_id: int or str
1979+
:return:
1980+
"""
1981+
base_url = self.resource_url("issue")
1982+
url = f"{base_url}/{issue_key}/comment/{comment_id}/pin"
1983+
return self.put(url, data=True)
1984+
1985+
def issue_unpin_comment(self, issue_key: str, comment_id: T_id) -> T_resp_json:
1986+
"""
1987+
Unpin a comment on a Jira issue
1988+
:param issue_key: str
1989+
:param comment_id: int or str
1990+
:return:
1991+
"""
1992+
base_url = self.resource_url("issue")
1993+
url = f"{base_url}/{issue_key}/comment/{comment_id}/pin"
1994+
return self.put(url, data=False)
1995+
19741996
def scrap_regex_from_issue(self, issue: str, regex: str):
19751997
"""
19761998
This function scrapes the output of the given regex matches from the issue's description and comments.

atlassian/rest_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ def request(
470470
url += ("&" if params or params_already_in_url else "") + "&".join(flags or [])
471471
json_dump = None
472472
if files is None:
473-
data = None if not data else dumps(data)
473+
data = None if data is None else dumps(data)
474474
json_dump = None if not json else dumps(json)
475475

476476
headers = headers or self.default_headers
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
responses['true'] = {}
2+
responses['false'] = {}

tests/test_jira.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ def test_get_issue_comment_not_found(self):
4646
with self.assertRaises(HTTPError):
4747
self.jira.epic_issues("BAR-11")
4848

49+
def test_pin_issue_comment(self):
50+
"""Can pin a comment on an issue"""
51+
self.jira.issue_pin_comment("FOO-123", 10000)
52+
53+
def test_unpin_issue_comment(self):
54+
"""Can unpin a comment on an issue"""
55+
self.jira.issue_unpin_comment("FOO-123", 10000)
56+
4957
def test_post_issue_with_invalid_request(self):
5058
"""Post an issue but receive a 400 error response"""
5159
with self.assertRaises(HTTPError):

0 commit comments

Comments
 (0)