Skip to content

[Jira] Add: Remote link: Application #1455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions atlassian/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -1776,6 +1776,7 @@ def create_or_update_issue_remote_links(
icon_url=None,
icon_title=None,
status_resolved=False,
application: dict = {},
):
"""
Add Remote Link to Issue, update url if global_id is passed
Expand All @@ -1787,6 +1788,7 @@ def create_or_update_issue_remote_links(
:param icon_url: str, OPTIONAL: Link to a 16x16 icon representing the type of the object in the remote system
:param icon_title: str, OPTIONAL: Text for the tooltip of the main icon describing the type of the object in the remote system
:param status_resolved: bool, OPTIONAL: if set to True, Jira renders the link strikethrough
:param application: dict, OPTIONAL: Application description
"""
base_url = self.resource_url("issue")
url = "{base_url}/{issue_key}/remotelink".format(base_url=base_url, issue_key=issue_key)
Expand All @@ -1802,6 +1804,8 @@ def create_or_update_issue_remote_links(
if icon_title:
icon_data["title"] = icon_title
data["object"]["icon"] = icon_data
if application:
data["application"] = application
return self.post(url, data=data)

def get_issue_remote_link_by_id(self, issue_key, link_id):
Expand Down
17 changes: 17 additions & 0 deletions tests/responses/jira/rest/api/2/issue/FOO-123/remotelink/POST
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
responses[
'{"object": {"url": "https://confluence.atlassian-python.atlassian.net/display/Test", "title": "Unused link text", "status": {"resolved": false}}}'
] = {
"id": 10000,
"self": "https://atlassian-python.atlassian.net/rest/api/2/issue/FOO-123/remotelink/10000",
"application": {},
}
responses[
'{"object": {"url": "https://confluence.atlassian-python.atlassian.net/display/Test", "title": "Unused link text", "status": {"resolved": false}}, "globalId": "appId=00000000-0000-0000-0000-000000000000&pageId=0", "application": {"type": "com.atlassian.confluence", "name": "Confluence"}}'
] = {
"id": 10000,
"self": "https://atlassian-python.atlassian.net/rest/api/2/issue/FOO-123/remotelink/10000",
"application": {
"type": "com.atlassian.confluence",
"name": "Confluence",
},
}
37 changes: 37 additions & 0 deletions tests/test_jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,40 @@ def test_delete_issue_property_not_found(self):
self.jira.get_issue_property("FOO-123", "NotFoundBar1")
with self.assertRaises(HTTPError):
self.jira.get_issue_property("FOONotFound-123", "NotFoundBar1")

def test_post_issue_remotelink(self):
"""Create a new remote link"""
resp = self.jira.create_or_update_issue_remote_links(
"FOO-123",
"https://confluence.atlassian-python.atlassian.net/display/Test",
"Unused link text",
)
self.assertEqual(resp["id"], 10000)
self.assertEqual(
resp["self"], "https://atlassian-python.atlassian.net/rest/api/2/issue/FOO-123/remotelink/10000"
)
self.assertDictEqual(resp["application"], {})

def test_post_issue_remotelink_confluence(self):
"""Create a new Confluence remote link"""
resp = self.jira.create_or_update_issue_remote_links(
"FOO-123",
"https://confluence.atlassian-python.atlassian.net/display/Test",
"Unused link text",
global_id="appId=00000000-0000-0000-0000-000000000000&pageId=0",
application={
"type": "com.atlassian.confluence",
"name": "Confluence",
},
)
self.assertEqual(resp["id"], 10000)
self.assertEqual(
resp["self"], "https://atlassian-python.atlassian.net/rest/api/2/issue/FOO-123/remotelink/10000"
)
self.assertDictEqual(
resp["application"],
{
"type": "com.atlassian.confluence",
"name": "Confluence",
},
)