Implement an analizing for a whole test plan
test_run field can accept an ID for test plan.
Code will detect automatically which Id was entered: TestRun's or TestPlan's
The list of analized test will be stored in the TestRun model
and will not be proceeded in the case of reruning TestRun
PRODX-35956
Change-Id: I91b59a6a6abc932e2026b05428d408a5dec31134
diff --git a/testrail_bot/control/views.py b/testrail_bot/control/views.py
index 2c9f0b2..847bc3c 100644
--- a/testrail_bot/control/views.py
+++ b/testrail_bot/control/views.py
@@ -30,7 +30,8 @@
form = forms.TestRunForm(instance=run)
return render(request, "control/update_run.html",
- {"form": form, "run_id": run_id})
+ {"form": form, "run_id": run_id, "checked_tests":
+ run.checked_tests})
def create_run(request):
@@ -64,8 +65,13 @@
def submit_run(request, run_id):
run = models.TestRailTestRun.objects.get(pk=run_id)
- testrail_run = test_rail_api.get_run_by_id(run.run_id)
- run_name = ''
+ 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:
@@ -75,19 +81,12 @@
path = os.path.join(models.fs.location, report_name)
with open(path, "w"):
pass
- form = forms.TestRunForm(request.POST)
- run_date = None
- if form.is_valid():
- run_date = datetime.datetime.combine(
- form.cleaned_data["timestamp"] + datetime.timedelta(days=1),
- datetime.datetime.min.time()).timestamp()
report = models.TestRailReport(
report_name=report_name,
path=path)
report.save()
- process_run.delay(run_id, report.id, path)
-
+ process_run.delay(run_id, report.id, path, is_testplan)
return redirect("single_report", report.id)