From 341bd084b0ea24aa5fb2c3ab6a22848ca3c5a9c7 Mon Sep 17 00:00:00 2001 From: "Mr. Senko" Date: Mon, 18 May 2020 22:13:31 +0300 Subject: [PATCH] Add LR to TE after creating bug in Bugzilla via 1-click. Refs #479 NOTE: the FE still needs to refresh the UI once the 'Report' button is clicked which will be implemented together with TR page UI redesign by @asankov. --- tcms/issuetracker/bugzilla_integration.py | 10 +++++++++- tcms/issuetracker/tests/test_bugzilla.py | 8 ++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tcms/issuetracker/bugzilla_integration.py b/tcms/issuetracker/bugzilla_integration.py index 84a3b4341b..6c4950f692 100644 --- a/tcms/issuetracker/bugzilla_integration.py +++ b/tcms/issuetracker/bugzilla_integration.py @@ -8,6 +8,7 @@ from django.conf import settings +from tcms.core.contrib.linkreference.models import LinkReference from tcms.issuetracker import base @@ -96,7 +97,14 @@ def report_issue_from_testexecution(self, execution, user): args['comment'] = self._report_comment(execution) try: - return self.one_click_report(execution, user, args) + new_bug_url = self.one_click_report(execution, user, args) + # and also add a link reference that will be shown in the UI + LinkReference.objects.get_or_create( + execution=execution, + url=new_bug_url, + is_defect=True, + ) + return new_bug_url except Fault: pass diff --git a/tcms/issuetracker/tests/test_bugzilla.py b/tcms/issuetracker/tests/test_bugzilla.py index 15f5f016b6..8d49fdf64f 100644 --- a/tcms/issuetracker/tests/test_bugzilla.py +++ b/tcms/issuetracker/tests/test_bugzilla.py @@ -4,6 +4,7 @@ import unittest from urllib.parse import urlencode +from tcms.core.contrib.linkreference.models import LinkReference from tcms.issuetracker.types import Bugzilla from tcms.management.models import Version from tcms.rpc.tests.utils import APITestCase @@ -152,3 +153,10 @@ def test_report_issue_from_test_execution_1click_works(self): component.name, test_case.text]: self.assertIn(expected_string, last_comment['text']) + + # verify that LR has been added to TE + self.assertTrue(LinkReference.objects.filter( + execution=execution2, + url=result['response'], + is_defect=True, + ).exists())