diff --git a/README.md b/README.md index 58c714b..5f46b0d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,11 @@ +# COMP-0233 Archive + +This fork is part of one of the exercises in UCL's COMP0233 ["Research Software Engineering with Python"](https://github.com/UCL-COMP0233-22-23/RSE-Classwork) course. The course is completed, and all repositories are now archived. + +([The following group work](https://github.com/bwan1/times-tests/tree/james).) + +--- + In this exercise, you will be given a few lines of code that perform a certain task (that you will have to understand) and then write an automated test that checks whether that task is performed correctly. ## Step 0 diff --git a/__pycache__/test_times.cpython-38-pytest-7.1.2.pyc b/__pycache__/test_times.cpython-38-pytest-7.1.2.pyc new file mode 100644 index 0000000..8eeaf83 Binary files /dev/null and b/__pycache__/test_times.cpython-38-pytest-7.1.2.pyc differ diff --git a/__pycache__/times.cpython-38.pyc b/__pycache__/times.cpython-38.pyc new file mode 100644 index 0000000..cfd1921 Binary files /dev/null and b/__pycache__/times.cpython-38.pyc differ diff --git a/test_times.py b/test_times.py new file mode 100644 index 0000000..72ee696 --- /dev/null +++ b/test_times.py @@ -0,0 +1,8 @@ +from times import time_range, compute_overlap_time + +def test_given_input(): + large = time_range("2010-01-12 10:00:00", "2010-01-12 12:00:00") + short = time_range("2010-01-12 10:30:00", "2010-01-12 10:45:00", 2, 60) + result = compute_overlap_time(large, short) + 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')] + assert result == expected \ No newline at end of file diff --git a/times.py b/times.py index d57f401..a7361a1 100644 --- a/times.py +++ b/times.py @@ -18,9 +18,4 @@ def compute_overlap_time(range1, range2): low = max(start1, start2) high = min(end1, end2) overlap_time.append((low, high)) - return overlap_time - -if __name__ == "__main__": - large = time_range("2010-01-12 10:00:00", "2010-01-12 12:00:00") - short = time_range("2010-01-12 10:30:00", "2010-01-12 10:45:00", 2, 60) - print(compute_overlap_time(large, short)) \ No newline at end of file + return overlap_time \ No newline at end of file