Merge branch 'develop/fix_nobreaks_calculator' into 'master'
Fix bug in calculator in "no breaks" case Closes #134 See merge request cara/cara!128
This commit is contained in:
commit
93e12464ed
2 changed files with 15 additions and 1 deletions
|
|
@ -350,7 +350,7 @@ class FormData:
|
|||
"""
|
||||
if not breaks:
|
||||
# If there are no breaks, the interval is the start and end.
|
||||
return models.SpecificInterval(((start, finish),))
|
||||
return models.SpecificInterval(((start/60, finish/60),))
|
||||
|
||||
# Order the breaks by their start-time, and ensure that they are monotonic
|
||||
# and that the start of one break happens after the end of another.
|
||||
|
|
|
|||
|
|
@ -303,6 +303,20 @@ def test_valid_no_lunch(baseline_form):
|
|||
assert baseline_form.validate() is None
|
||||
|
||||
|
||||
def test_no_breaks(baseline_form):
|
||||
# Check that the times are correct in the absence of breaks.
|
||||
baseline_form.lunch_option = False
|
||||
baseline_form.coffee_breaks = 0
|
||||
baseline_form.activity_start = 9 * 60
|
||||
baseline_form.activity_finish = 17 * 60
|
||||
baseline_form.infected_start = 10 * 60
|
||||
baseline_form.infected_finish = 15 * 60
|
||||
exposed_correct = ((9, 17),)
|
||||
infected_correct = ((10, 15),)
|
||||
assert baseline_form.exposed_present_interval().present_times == exposed_correct
|
||||
assert baseline_form.infected_present_interval().present_times == infected_correct
|
||||
|
||||
|
||||
def test_coffee_lunch_breaks(baseline_form):
|
||||
baseline_form.coffee_duration = 30
|
||||
baseline_form.coffee_breaks = 4
|
||||
|
|
|
|||
Loading…
Reference in a new issue