| 1 | """This tests that a timedelta can be used as the second argument to between. |
| 2 | |
| 3 | This is useful when you do not want to calculate this yourself. |
| 4 | """ |
| 5 | |
| 6 | from datetime import timedelta |
| 7 | |
| 8 | import pytest |
| 9 | |
| 10 | |
| 11 | @pytest.mark.parametrize( |
| 12 | ("start", "delta", "count"), |
| 13 | [ |
| 14 | ("20190301", timedelta(days=3), 0), |
| 15 | ("20190301", timedelta(days=5), 1), |
| 16 | ("20190301", timedelta(days=3, hours=8), 0), |
| 17 | ("20190301", timedelta(days=3, hours=9), 1), |
| 18 | ("20190301", timedelta(days=3, hours=8, seconds=1), 1), |
| 19 | ("20190304", timedelta(days=1), 1), |
| 20 | ("20190304", timedelta(hours=8), 0), |
| 21 | ("20190304", timedelta(hours=9), 1), |
| 22 | ], |
| 23 | ) |
| 24 | def test_event_with_between_and_timedelta(calendars, start, delta, count): |
| 25 | """The event starts at 20190304T080000 and ends at 20190304T080000""" |
| 26 | events = calendars.one_event.between(start, delta) |
| 27 | assert len(events) == count |