| 1 | """Test the properties of events.""" |
| 2 | |
| 3 | import pytest |
| 4 | |
| 5 | |
| 6 | def test_event_has_summary(calendars): |
| 7 | event = next(calendars.one_event.all()) |
| 8 | assert event["SUMMARY"] == "test1" |
| 9 | |
| 10 | |
| 11 | @pytest.mark.parametrize("attribute", ["DTSTART", "DTEND"]) |
| 12 | def test_recurrent_events_change_start_and_end(calendars, attribute): |
| 13 | events = calendars.three_events_one_edited.all() |
| 14 | values = set(event[attribute] for event in events) |
| 15 | assert len(values) == 3 |
| 16 | |
| 17 | |
| 18 | @pytest.mark.parametrize("index", [1, 2]) |
| 19 | def test_duration_stays_the_same(calendars, index): |
| 20 | events = list(calendars.three_events_one_edited.all()) |
| 21 | duration1 = events[0]["DTEND"].dt - events[0]["DTSTART"].dt |
| 22 | duration2 = events[index]["DTEND"].dt - events[index]["DTSTART"].dt |
| 23 | assert duration1 == duration2 |
| 24 | |
| 25 | |
| 26 | def test_attributes_are_created(calendars): |
| 27 | """Some properties should be part of every event |
| 28 | |
| 29 | This is, even if they are not given in the event at the beginning.""" |
| 30 | events = calendars.discourse_no_dtend.at((2019, 1, 17)) |
| 31 | assert len(events) == 1 |
| 32 | event = events[0] |
| 33 | assert "DTEND" in event |