Skip to content

Commit

Permalink
UCL-RITS#92 fixture task
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidScobie committed Nov 17, 2020
1 parent 90c5065 commit cb65383
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
Binary file modified week5-testing/__pycache__/test_times.cpython-38-pytest-6.1.1.pyc
Binary file not shown.
Binary file modified week5-testing/__pycache__/times.cpython-38.pyc
Binary file not shown.
26 changes: 14 additions & 12 deletions week5-testing/fixture.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
- regualar overlap:
test_times1: time_range("2010-01-12 10:00:00", "2010-01-12 12:00:00")
test_times2: time_range("2010-01-12 10:30:00", "2010-01-12 10:45:00",2,60)
expected: [('2010-01-12 10:30:00', '2010-01-12 10:37:00'), ('2010-01-12 10:38:00', '2010-01-12 10:45:00')]
-edge case:
test_times1: time_range("2010-01-12 10:45:00", "2010-01-12 12:00:00")
test_times2: time_range("2010-01-12 10:30:00", "2010-01-12 10:45:00",2,60)
expected: []
-no overlap:
test_times1: time_range("2010-01-12 10:45:00", "2010-01-12 12:00:00")
test_times2: time_range("2010-01-12 10:30:00", "2010-01-12 10:35:00",2,60)
expected: []
- overlap:
test_times1: ["2010-01-12 10:00:00", "2010-01-12 12:00:00"]
test_times2: ["2010-01-12 10:30:00", "2010-01-12 10:45:00",2,60]
expected:
- ['2010-01-12 10:30:00', '2010-01-12 10:37:00']
- ['2010-01-12 10:38:00', '2010-01-12 10:45:00']
- edge case:
test_times1: ["2010-01-12 10:45:00", "2010-01-12 12:00:00"]
test_times2: ["2010-01-12 10:30:00", "2010-01-12 10:45:00",2,60]
expected: []
- no overlap:
test_times1: ["2010-01-12 10:45:00", "2010-01-12 12:00:00"]
test_times2: ["2010-01-12 10:30:00", "2010-01-12 10:35:00",2,60]
expected: []



14 changes: 11 additions & 3 deletions week5-testing/test_times.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@

from times import compute_overlap_time, time_range
import pytest
import yaml

with open('fixture.yaml') as fixture_file:
fixture = yaml.safe_load(fixture_file)

overlap_times_range_1=fixture[0]['overlap']['test_times1']
overlap_t_r_1_first=overlap_times_range_1[0]
overlap_t_r_1_2nd=overlap_times_range_1[1]


@pytest.mark.parametrize("test_times1,test_times2,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(fixture[0]['overlap']['test_times1'][0],fixture[0]['overlap']['test_times1'][1]),
time_range(fixture[0]['overlap']['test_times2'][0],fixture[0]['overlap']['test_times2'][1],fixture[0]['overlap']['test_times2'][2],fixture[0]['overlap']['test_times2'][3]),
[(fixture[0]['overlap']['expected'][0][0], fixture[0]['overlap']['expected'][0][1]), (fixture[0]['overlap']['expected'][1][0], fixture[0]['overlap']['expected'][1][1])]),
(time_range("2010-01-12 10:45:00", "2010-01-12 12:00:00"),
time_range("2010-01-12 10:30:00", "2010-01-12 10:45:00", 2, 60),
[]),
Expand Down

0 comments on commit cb65383

Please sign in to comment.