Use run_name field to save display name of the run, and testrun_pattern as a pattern to filter testruns in testrail api
PRODX-35953
Change-Id: I3222313d3f9accae345b36f4a261c80911b29afb
diff --git a/testrail_bot/control/views.py b/testrail_bot/control/views.py
index 7a34327..bff73e0 100644
--- a/testrail_bot/control/views.py
+++ b/testrail_bot/control/views.py
@@ -84,18 +84,25 @@
def submit_run(request, run_id):
run = models.TestRailTestRun.objects.get(pk=run_id)
is_testplan = test_rail_api.is_testplan(run.run_id)
-
if is_testplan:
testrail_run = test_rail_api.get_plan_by_id(run.run_id)
else:
testrail_run = test_rail_api.get_run_by_id(run.run_id)
- run_name = 'Plan-' if is_testplan else "Run-"
if not run.run_name:
- run_name += testrail_run['name']
- if run.test_pattern:
- run_name += "-" + run.test_pattern
+ if is_testplan:
+ _name = f"Plan {testrail_run['name']}"
+ else:
+ parent_plan_id = testrail_run["plan_id"]
+ parent_plan_name = \
+ test_rail_api.get_plan_by_id(parent_plan_id)["name"]
+ _name = f"Run {testrail_run['name']} from {parent_plan_name}"
+ run.run_name = _name
+ run.save()
+
report_name = "{}-run_id-{}-date-{}".format(
- run_name, run.run_id, datetime.datetime.isoformat(datetime.datetime.now()))
+ run.run_name,
+ run.run_id,
+ datetime.datetime.isoformat(datetime.datetime.now()))
path = os.path.join(models.fs.location, report_name)
with open(path, "w"):
pass