forked from UCL-RITS/rse-classwork-2020
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests combined into single function using pytest parameterize Answers U…
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from times import time_range, compute_overlap_time | ||
import pytest | ||
@pytest.mark.parametrize("range1,range2,expected",[ | ||
(time_range("2010-01-12 10:00:00", "2010-01-12 12:00:00"), | ||
time_range("2010-01-12 10:30:00", "2010-01-12 10:45:00", 2, 60), | ||
[('2010-01-12 10:30:00', '2010-01-12 10:37:00'), ('2010-01-12 10:38:00', '2010-01-12 10:45:00')]), | ||
(time_range("2019-01-10 10:00:00", "2019-01-10 11:00:00"), | ||
time_range("2019-01-10 11:20:00", "2019-01-10 11:30:00"), | ||
[]), | ||
(time_range("2010-01-12 10:00:00", "2010-01-12 13:00:00",2,60), | ||
time_range("2010-01-12 10:30:00", "2010-01-12 11:35:00", 2, 60), | ||
[('2010-01-12 10:30:00', '2010-01-12 11:02:00'), | ||
('2010-01-12 11:03:00', '2010-01-12 11:29:30'), | ||
('2010-01-12 11:30:30', '2010-01-12 11:35:00')]), | ||
(time_range("2010-01-12 10:00:00", "2010-01-12 13:00:00"), | ||
time_range("2010-01-12 13:00:00", "2010-01-12 14:00:00"), | ||
[('2010-01-12 13:00:00', '2010-01-12 13:00:00')]) | ||
]) | ||
|
||
|
||
|
||
def test_eval(range1,range2, expected): | ||
assert compute_overlap_time(range1,range2) == expected | ||
|
||
def write_backwards_time(): | ||
with pytest.raises(ValueError): | ||
large = time_range("2010-01-12 14:00:00", "2010-01-12 13:00:00") |