Skip to content

Commit

Permalink
For Issue Tracker integration use Product/Version from execution.build
Browse files Browse the repository at this point in the history
similar to previous commits use Product/Version values based on the
Build a specific TestExecution status was recorded against instead
of using values coming from TestRun->TestPlan which can change in the
future.

NOTE: execution.build is initialized with run.build and then may change
its value if we're recording results against multiple builds inside the
same TestRun.

(For example mark some executions as PASS, others as FAIL;
then update TR to a newer Build; retest and mark the FAIL results as
PASS)
  • Loading branch information
atodorov committed Dec 3, 2023
1 parent 5ef7ed2 commit 48a33a7
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 21 deletions.
11 changes: 7 additions & 4 deletions tcms/issuetracker/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,17 @@ def _report_comment(self, execution, user=None): # pylint: disable=no-self-use
{reporter}
**Product:**
{execution.run.plan.product.name}
{execution.build.version.product.name}
**Component(s):**
{self.get_case_components(execution.case)}
**Version:**
{execution.build.version.value}
**Version-Release number** (if applicable):
**Build:**
{execution.build.name}
**Component(s):**
{self.get_case_components(execution.case)}
**Steps to reproduce**:
{txt}
Expand Down
4 changes: 2 additions & 2 deletions tcms/issuetracker/bugzilla_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ def _report_issue(self, execution, user):
to a URL with some of the values pre-defined as query parameters!
"""
args = {
"product": execution.run.plan.product.name,
"product": execution.build.version.product.name,
"component": self.get_case_components(execution.case),
"version": execution.run.plan.product_version.value,
"version": execution.build.version.value,
"short_desc": f"Test case failure: {execution.case.summary}",
"comment": self._report_comment(execution, user),
}
Expand Down
4 changes: 2 additions & 2 deletions tcms/issuetracker/kiwitcms.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def _report_issue(self, execution, user):
data = {
"reporter": user,
"summary": f"Failed test: {execution.case.summary}",
"product": execution.run.plan.product,
"version": execution.run.plan.product_version,
"product": execution.build.version.product,
"version": execution.build.version,
"build": execution.build,
"text": self._report_comment(execution, user),
"_execution": execution,
Expand Down
2 changes: 1 addition & 1 deletion tcms/issuetracker/tests/test_azureboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def test_report_issue_from_test_execution_1click_works(self):
for expected_string in [
f"Filed from execution {self.execution_1.get_full_url()}",
"Reporter",
self.execution_1.run.plan.product.name,
self.execution_1.build.version.product.name,
self.component.name,
"Steps to reproduce",
self.execution_1.case.text,
Expand Down
2 changes: 1 addition & 1 deletion tcms/issuetracker/tests/test_bitbucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def test_report_issue_from_test_execution_1click_works(self):
for expected_string in [
f"Filed from execution {self.execution_1.get_full_url()}",
"Reporter",
self.execution_1.run.plan.product.name,
self.execution_1.build.version.product.name,
self.component.name,
"Steps to reproduce",
self.execution_1.case.text,
Expand Down
6 changes: 6 additions & 0 deletions tcms/issuetracker/tests/test_bugzilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ def test_report_issue_from_test_execution_falls_back_to_query_params(self):
test_case.save() # will generate history object

test_run = TestRunFactory(plan=test_plan)
test_run.build.version = version
test_run.build.save()

execution2 = TestExecutionFactory(
run=test_run, case=test_case, build=test_run.build
)
Expand Down Expand Up @@ -144,6 +147,9 @@ def test_report_issue_from_test_execution_1click_works(self):
test_case.save() # will generate history object

test_run = TestRunFactory(plan=test_plan)
test_run.build.version = version
test_run.build.save()

execution2 = TestExecutionFactory(
run=test_run, case=test_case, build=test_run.build
)
Expand Down
2 changes: 1 addition & 1 deletion tcms/issuetracker/tests/test_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def test_report_issue_from_test_execution_1click_works(self):
for expected_string in [
f"Filed from execution {self.execution_1.get_full_url()}",
"Reporter",
self.execution_1.run.plan.product.name,
self.execution_1.build.version.product.name,
self.component.name,
"Steps to reproduce",
self.execution_1.case.text,
Expand Down
2 changes: 1 addition & 1 deletion tcms/issuetracker/tests/test_gitlab_com.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def test_report_issue_from_test_execution_1click_works(self):
for expected_string in [
f"Filed from execution {self.execution_1.get_full_url()}",
"Reporter",
self.execution_1.run.plan.product.name,
self.execution_1.build.version.product.name,
self.component.name,
"Steps to reproduce",
self.execution_1.case.text,
Expand Down
2 changes: 1 addition & 1 deletion tcms/issuetracker/tests/test_gitlab_ee.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def test_report_issue_from_test_execution_1click_works(self):
for expected_string in [
f"Filed from execution {self.execution_1.get_full_url()}",
"Reporter",
self.execution_1.run.plan.product.name,
self.execution_1.build.version.product.name,
self.component.name,
"Steps to reproduce",
self.execution_1.case.text,
Expand Down
6 changes: 3 additions & 3 deletions tcms/issuetracker/tests/test_jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def _fixture_setup(self):
self.execution_1.run.save()

# this is the name of the Project in JIRA. Key is "KT"
self.execution_1.run.plan.product.name = "Kiwi TCMS"
self.execution_1.run.plan.product.save()
self.execution_1.build.version.product.name = "Kiwi TCMS"
self.execution_1.build.version.product.save()

self.component = ComponentFactory(
name="JIRA integration", product=self.execution_1.run.plan.product
Expand Down Expand Up @@ -129,7 +129,7 @@ def test_report_issue_from_test_execution_1click_works(self):
for expected_string in [
f"Filed from execution {self.execution_1.get_full_url()}",
"Reporter",
self.execution_1.run.plan.product.name,
self.execution_1.build.version.product.name,
self.component.name,
"Steps to reproduce",
self.execution_1.case.text,
Expand Down
2 changes: 1 addition & 1 deletion tcms/issuetracker/tests/test_kiwitcms.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_report_issue_from_test_execution_1click_works(self):
for expected_string in [
f"Filed from execution {self.execution_1.get_full_url()}",
"Reporter",
self.execution_1.run.plan.product.name,
self.execution_1.build.version.product.name,
self.component.name,
"Steps to reproduce",
self.execution_1.case.text,
Expand Down
6 changes: 3 additions & 3 deletions tcms/issuetracker/tests/test_redmine.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def _fixture_setup(self):
self.execution_1.case.save() # will generate history object

# this is the name of the Redmine Project
self.execution_1.run.plan.product.name = "Integration with Kiwi TCMS"
self.execution_1.run.plan.product.save()
self.execution_1.build.version.product.name = "Integration with Kiwi TCMS"
self.execution_1.build.version.product.save()

self.component = ComponentFactory(
name="Redmine integration", product=self.execution_1.run.plan.product
Expand Down Expand Up @@ -129,7 +129,7 @@ def test_report_issue_from_test_execution_1click_works(self):
for expected_string in [
f"Filed from execution {self.execution_1.get_full_url()}",
"Reporter",
self.execution_1.run.plan.product.name,
self.execution_1.build.version.product.name,
self.component.name,
"Steps to reproduce",
self.execution_1.case.text,
Expand Down
2 changes: 1 addition & 1 deletion tcms/issuetracker/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def get_project_from_jira(self, execution):
.. versionadded:: 11.4
"""
search_for = execution.run.plan.product.name.lower()
search_for = execution.build.version.product.name.lower()
projects_in_jira = self.rpc.projects()
for project in self.rpc.projects():
if (project.name.lower() == search_for) or (
Expand Down

0 comments on commit 48a33a7

Please # to comment.