Skip to content

Commit

Permalink
Modified expected_duration property to reflect business logic better k…
Browse files Browse the repository at this point in the history
  • Loading branch information
gasharova authored and APiligrim committed Mar 24, 2021
1 parent 5202103 commit 7e4e9fd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
12 changes: 8 additions & 4 deletions tcms/testcases/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
import vinaigrette
from datetime import timedelta
from django.conf import settings
from django.db import models
from django.db.models import ObjectDoesNotExist
Expand Down Expand Up @@ -55,14 +56,17 @@ class TestCase(models.Model, UrlMixin):
requirement = models.CharField(max_length=255, blank=True, null=True)
notes = models.TextField(blank=True, null=True)
text = models.TextField(blank=True)
setup_duration = models.DurationField(db_index=True, null=True, blank=True) or 0
testing_duration = models.DurationField(db_index=True, null=True, blank=True) or 0
setup_duration = models.DurationField(db_index=True, null=True, blank=True)
testing_duration = models.DurationField(db_index=True, null=True, blank=True)

@property
def expected_duration(self):
if not self.setup_duration and not self.testing_duration:
return 0
return self.setup_duration + self.testing_duration
return None
result = timedelta(0)
result += self.setup_duration or timedelta(0)
result += self.testing_duration or timedelta(0)
return result

case_status = models.ForeignKey(TestCaseStatus, on_delete=models.CASCADE)
category = models.ForeignKey(
Expand Down
12 changes: 0 additions & 12 deletions tcms/testcases/templates/testcases/mutable.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,6 @@
</div>
</div>

<div class="form-group">
<label class="col-md-1 col-lg-1">{% trans "Setup duration" %}</label>
<div class="col-md-3 col-lg-3">
<!-- https://github.com/koss-lebedev/bootstrap-duration-picker -->
</div>

<label class="col-md-1 col-lg-1">{% trans "Testing duration" %}</label>
<div class="col-md-3 col-lg-3">
<!-- https://github.com/koss-lebedev/bootstrap-duration-picker -->
</div>
</div>

<div class="form-group">
<div class="col-md-12 col-lg-12">
<label class="{% if form.text.errors %}has-error{% endif %}">{% trans "Text" %}:</label>
Expand Down

0 comments on commit 7e4e9fd

Please sign in to comment.