Skip to content

Commit

Permalink
Update TestCaseRun.tested_by when setting status. Fixes #459
Browse files Browse the repository at this point in the history
  • Loading branch information
atodorov committed Sep 2, 2018
1 parent 200cf3d commit 2a847c4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
7 changes: 4 additions & 3 deletions tcms/testruns/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,11 @@ class TestCaseRunStatus(TCMSActionModel):
FAILED = 'FAILED'
BLOCKED = 'BLOCKED'
PASSED = 'PASSED'
IDLE = 'IDLE'

complete_status_names = ('PASSED', 'ERROR', 'FAILED', 'WAIVED')
failure_status_names = ('ERROR', 'FAILED')
idle_status_names = ('IDLE',)
complete_status_names = (PASSED, 'ERROR', FAILED, 'WAIVED')
failure_status_names = ('ERROR', FAILED)
idle_status_names = (IDLE,)

id = models.AutoField(db_column='case_run_status_id', primary_key=True)
name = models.CharField(max_length=60, blank=True, unique=True)
Expand Down
3 changes: 2 additions & 1 deletion tcms/testruns/urls/run_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
url(r'^(?P<run_id>\d+)/update/$', views.update_case_run_text,
name='testruns-update_case_run_text'),
url(r'^update-assignee/$', views.UpdateAssigneeView.as_view()),
url(r'^case-run-update-status/$', views.UpdateCaseRunStatusView.as_view()),
url(r'^case-run-update-status/$', views.UpdateCaseRunStatusView.as_view(),
name='testruns-update_caserun_status'),
]
3 changes: 3 additions & 0 deletions tcms/testruns/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-

import json
from datetime import datetime
from http import HTTPStatus
from functools import reduce

Expand Down Expand Up @@ -956,6 +957,8 @@ def post(self, request):
for caserun_pk in object_ids:
test_case_run = get_object_or_404(TestCaseRun, pk=int(caserun_pk))
test_case_run.case_run_status_id = status_id
test_case_run.tested_by = request.user
test_case_run.close_date = datetime.now()
test_case_run.save()

return JsonResponse({'rc': 0, 'response': 'ok'})
4 changes: 3 additions & 1 deletion tcms/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ class BaseCaseRun(BasePlanCase):
def setUpTestData(cls):
super(BaseCaseRun, cls).setUpTestData()

# todo: we need a linter to find all places where we get statuses
# by hard-coded names instead of class based attribute constants!
cls.case_run_status_idle = TestCaseRunStatus.objects.get(name='IDLE')

cls.build = BuildFactory(product=cls.product)
Expand All @@ -184,7 +186,7 @@ def setUpTestData(cls):
default_tester=cls.tester)

cls.case_run_1, cls.case_run_2, cls.case_run_3 = [
TestCaseRunFactory(assignee=cls.tester, tested_by=cls.tester,
TestCaseRunFactory(assignee=cls.tester,
run=cls.test_run, build=cls.build,
case_run_status=cls.case_run_status_idle,
case=case, sortkey=i * 10)
Expand Down

0 comments on commit 2a847c4

Please sign in to comment.