Skip to content

Commit

Permalink
feat: add flag for incident creation
Browse files Browse the repository at this point in the history
  • Loading branch information
AlthausKonstantin authored and waynesun09 committed Apr 16, 2024
1 parent 0af0542 commit f1761cc
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/pylero/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,9 @@ def __create_incident_report(
return incident_report.work_item_id

@tx_wrapper
def add_test_record_by_object(self, test_record, manual_state_change=False):
def add_test_record_by_object(
self, test_record, manual_state_change=False, create_incident=True
):
"""method add_test_record_by_object, adds a test record for the given
test case based on the TestRecord object passed in.
In addition, the test run is checked for completeness and the test
Expand All @@ -995,6 +997,8 @@ def add_test_record_by_object(self, test_record, manual_state_change=False):
test_record (TestRecord or Polarion TestRecord):
manual_state_change (boolean): Change test run state
automatically or manual.
create_incident (boolean): Create an incident report if the test
case fails and no incident is linked.
Returns:
None
Expand All @@ -1009,7 +1013,11 @@ def add_test_record_by_object(self, test_record, manual_state_change=False):
suds_object = test_record._suds_object
elif isinstance(test_record, TestRecord()._suds_object.__class__):
suds_object = test_record
if test_record.result == "failed" and not test_record.defect_case_id:
if (
test_record.result == "failed"
and not test_record.defect_case_id
and create_incident
):
test_record.defect_case_id = self.__create_incident_report(
test_case_id,
test_record,
Expand Down Expand Up @@ -1357,7 +1365,11 @@ def update_test_record_by_fields(

@tx_wrapper
def update_test_record_by_object(
self, test_case_id, test_record, manual_state_change=False
self,
test_case_id,
test_record,
manual_state_change=False,
create_incident=True,
):
"""method update_test_record_by_object, adds a test record for the
given test case based on the TestRecord object passed in.
Expand All @@ -1371,6 +1383,9 @@ def update_test_record_by_object(
test_record (TestRecord or Polarion TestRecord)
manual_state_change (boolean): Change the test
run result automatically or manual.
create_incident (boolean): Create an incident report if the test
record result is failed and no defect
case id is set.
Returns:
None
Expand All @@ -1387,7 +1402,11 @@ def update_test_record_by_object(
if test_case_id not in test_case_ids:
self.add_test_record_by_object(test_record)
else:
if test_record.result == "failed" and not test_record.defect_case_id:
if (
test_record.result == "failed"
and not test_record.defect_case_id
and create_incident
):
test_record.defect_case_id = self.__create_incident_report(
test_case_id, test_record
)
Expand Down

0 comments on commit f1761cc

Please sign in to comment.