Skip to content

Commit f1761cc

Browse files
AlthausKonstantinwaynesun09
authored andcommitted
feat: add flag for incident creation
1 parent 0af0542 commit f1761cc

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

src/pylero/test_run.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,9 @@ def __create_incident_report(
983983
return incident_report.work_item_id
984984

985985
@tx_wrapper
986-
def add_test_record_by_object(self, test_record, manual_state_change=False):
986+
def add_test_record_by_object(
987+
self, test_record, manual_state_change=False, create_incident=True
988+
):
987989
"""method add_test_record_by_object, adds a test record for the given
988990
test case based on the TestRecord object passed in.
989991
In addition, the test run is checked for completeness and the test
@@ -995,6 +997,8 @@ def add_test_record_by_object(self, test_record, manual_state_change=False):
995997
test_record (TestRecord or Polarion TestRecord):
996998
manual_state_change (boolean): Change test run state
997999
automatically or manual.
1000+
create_incident (boolean): Create an incident report if the test
1001+
case fails and no incident is linked.
9981002
9991003
Returns:
10001004
None
@@ -1009,7 +1013,11 @@ def add_test_record_by_object(self, test_record, manual_state_change=False):
10091013
suds_object = test_record._suds_object
10101014
elif isinstance(test_record, TestRecord()._suds_object.__class__):
10111015
suds_object = test_record
1012-
if test_record.result == "failed" and not test_record.defect_case_id:
1016+
if (
1017+
test_record.result == "failed"
1018+
and not test_record.defect_case_id
1019+
and create_incident
1020+
):
10131021
test_record.defect_case_id = self.__create_incident_report(
10141022
test_case_id,
10151023
test_record,
@@ -1357,7 +1365,11 @@ def update_test_record_by_fields(
13571365

13581366
@tx_wrapper
13591367
def update_test_record_by_object(
1360-
self, test_case_id, test_record, manual_state_change=False
1368+
self,
1369+
test_case_id,
1370+
test_record,
1371+
manual_state_change=False,
1372+
create_incident=True,
13611373
):
13621374
"""method update_test_record_by_object, adds a test record for the
13631375
given test case based on the TestRecord object passed in.
@@ -1371,6 +1383,9 @@ def update_test_record_by_object(
13711383
test_record (TestRecord or Polarion TestRecord)
13721384
manual_state_change (boolean): Change the test
13731385
run result automatically or manual.
1386+
create_incident (boolean): Create an incident report if the test
1387+
record result is failed and no defect
1388+
case id is set.
13741389
13751390
Returns:
13761391
None
@@ -1387,7 +1402,11 @@ def update_test_record_by_object(
13871402
if test_case_id not in test_case_ids:
13881403
self.add_test_record_by_object(test_record)
13891404
else:
1390-
if test_record.result == "failed" and not test_record.defect_case_id:
1405+
if (
1406+
test_record.result == "failed"
1407+
and not test_record.defect_case_id
1408+
and create_incident
1409+
):
13911410
test_record.defect_case_id = self.__create_incident_report(
13921411
test_case_id, test_record
13931412
)

0 commit comments

Comments
 (0)