Skip to content

Commit

Permalink
Add fields id, status & url for GitLab bug details
Browse files Browse the repository at this point in the history
  • Loading branch information
atodorov committed Nov 7, 2024
1 parent 9258cbc commit f3afa79
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
12 changes: 10 additions & 2 deletions tcms/issuetracker/tests/test_gitlab_com.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ def test_bug_id_from_url(self):
def test_details_for_public_url(self):
result = self.integration.details(self.existing_bug_url)

self.assertEqual("Hello GitLab Hosted", result["title"])
self.assertEqual(self.existing_bug_id, result["id"])
self.assertEqual("Here we start testing.", result["description"])
self.assertEqual("opened", result["status"])
self.assertEqual("Hello GitLab Hosted", result["title"])
self.assertEqual(self.existing_bug_url, result["url"])

def test_details_for_private_url(self):
bug_system = BugSystem.objects.create( # nosec:B106:hardcoded_password_funcarg
Expand All @@ -65,8 +68,13 @@ def test_details_for_private_url(self):

result = integration.details("https://gitlab.com/kiwitcms/katinar/-/issues/1")

self.assertEqual("Hello Private GitLab", result["title"])
self.assertEqual(1, result["id"])
self.assertEqual("Hello World", result["description"])
self.assertEqual("closed", result["status"])
self.assertEqual("Hello Private GitLab", result["title"])
self.assertEqual(
"https://gitlab.com/kiwitcms/katinar/-/issues/1", result["url"]
)

def test_auto_update_bugtracker(self):
repo_id = self.integration.repo_id
Expand Down
7 changes: 6 additions & 1 deletion tcms/issuetracker/tests/test_gitlab_ee.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,13 @@ def test_details_for_private_url(self):
"http://bugtracker.kiwitcms.org/root/katinar/-/issues/1"
)

self.assertEqual("Hello Private Issue", result["title"])
self.assertEqual(1, result["id"])
self.assertEqual("Created in secret via CLI", result["description"])
self.assertEqual("opened", result["status"])
self.assertEqual("Hello Private Issue", result["title"])
self.assertEqual(
"http://bugtracker.kiwitcms.org/root/katinar/-/issues/1", result["url"]
)

def test_auto_update_bugtracker(self):
repo_id = self.integration.repo_id
Expand Down
8 changes: 6 additions & 2 deletions tcms/issuetracker/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,14 @@ def details(self, url):
details b/c it will work for both public and private URLs.
"""
project = self.rpc.projects.get(self.repo_id)
issue = project.issues.get(self.bug_id_from_url(url))
issue_id = self.bug_id_from_url(url)
issue = project.issues.get(issue_id)
return {
"title": issue.title,
"id": issue_id,
"description": issue.description,
"status": issue.state,
"title": issue.title,
"url": url,
}

@property
Expand Down

0 comments on commit f3afa79

Please sign in to comment.