| 1 |
"""Check that we can still compute if start and end are swapped.""" |
| 2 |
|
| 3 |
from datetime import datetime |
| 4 |
|
| 5 |
import pytest |
| 6 |
|
| 7 |
|
| 8 |
def test_event_case(calendars): |
| 9 |
"""Test an event with swapped start and end.""" |
| 10 |
event = calendars.issue_132_swapped_start_and_end.first |
| 11 |
assert event.start.replace(tzinfo=None) == datetime(2023, 12, 18, 23, 30) |
| 12 |
assert event.end.replace(tzinfo=None) == datetime(2023, 12, 18, 23, 45) |
| 13 |
|
| 14 |
|
| 15 |
def test_todo_case(calendars): |
| 16 |
"""Test an event with swapped start and end.""" |
| 17 |
calendars.components = ["VTODO"] |
| 18 |
todo = calendars.issue_132_swapped_start_and_end.first |
| 19 |
print(todo) |
| 20 |
assert todo.start.replace(tzinfo=None) == datetime(2023, 12, 18, 23, 30) |
| 21 |
assert todo.end.replace(tzinfo=None) == datetime(2023, 12, 18, 23, 45) |
| 22 |
|
| 23 |
|
| 24 |
@pytest.mark.parametrize("skip_invalid", [True, False]) |
| 25 |
def test_old_example_works_now(calendars, ZoneInfo, skip_invalid): |
| 26 |
"""The old tests works now.""" |
| 27 |
calendars.skip_bad_series = skip_invalid |
| 28 |
events = calendars.end_before_start_event.at(2019) |
| 29 |
print(list(calendars.end_before_start_event.all())) |
| 30 |
assert len(events) == 1 |
| 31 |
event = events[0] |
| 32 |
assert event.start == datetime( |
| 33 |
2019, 3, 4, 8, tzinfo=ZoneInfo("Europe/Berlin") |
| 34 |
) |
| 35 |
assert event.end == datetime( |
| 36 |
2019, 3, 4, 8, 30, tzinfo=ZoneInfo("Europe/Berlin") |
| 37 |
) |