| 1 | """The objective of this test is to ensure that repeated events can be copied |
| 2 | into an ICAL calendar again without multiplying themselves to wrong dates. |
| 3 | """ |
| 4 | |
| 5 | import recurring_ical_events |
| 6 | |
| 7 | |
| 8 | def assert_event_does_not_duplicate(event): |
| 9 | for i, _ in enumerate(recurring_ical_events.of(event).all()): |
| 10 | assert i <= 1, event |
| 11 | |
| 12 | |
| 13 | def assert_events_do_not_duplicate(events): |
| 14 | assert events |
| 15 | for event in events: |
| 16 | assert_event_does_not_duplicate(event) |
| 17 | |
| 18 | |
| 19 | def test_simple_event(calendars): |
| 20 | """An event with no repetitions.""" |
| 21 | assert_events_do_not_duplicate(calendars.duration.at(2018)) |
| 22 | |
| 23 | |
| 24 | def test_rdate_event(calendars): |
| 25 | """An event with rdate.""" |
| 26 | assert_events_do_not_duplicate(calendars.rdate_hackerpublicradio.all()) |
| 27 | |
| 28 | |
| 29 | def test_rrule(calendars): |
| 30 | """An event with rrule and a number of events.""" |
| 31 | assert_events_do_not_duplicate(calendars.event_10_times.at(2020)) |
| 32 | |
| 33 | |
| 34 | def test_rrule_with_exdate(calendars): |
| 35 | """An event with rrule and exrule.""" |
| 36 | assert_events_do_not_duplicate(calendars.each_week_but_two_deleted.at(2019)) |
| 37 | |
| 38 | |
| 39 | def test_exdate_is_removed_because_it_is_not_needed(calendars): |
| 40 | """A repeated event removed RDATE and RRULE and as such should |
| 41 | also remove the EXDATE values.""" |
| 42 | for event in calendars.rdate.all(): |
| 43 | assert "EXDATE" not in event |