| 1 |
""" |
| 2 |
This tests the issue 20. Exdates seem to be ignored. |
| 3 |
https://github.com/niccokunzmann/python-recurring-ical-events/issues/20 |
| 4 |
|
| 5 |
Another issue of this calendar is that the UNTIL value ends one second |
| 6 |
before the next event. |
| 7 |
The event in February should be exluded therefore. |
| 8 |
""" |
| 9 |
|
| 10 |
import pytest |
| 11 |
|
| 12 |
|
| 13 |
@pytest.mark.parametrize( |
| 14 |
"exdate", |
| 15 |
|
| 16 |
[ |
| 17 |
"20191015T141500Z", |
| 18 |
"20191022T141500Z", |
| 19 |
"20191105T151500Z", |
| 20 |
"20191119T151500Z", |
| 21 |
"20191126T151500Z", |
| 22 |
"20191203T151500Z", |
| 23 |
"20191217T151500Z", |
| 24 |
"20191224T151500Z", |
| 25 |
"20191231T151500Z", |
| 26 |
], |
| 27 |
) |
| 28 |
def test_exdates_do_not_show_up(exdate, calendars): |
| 29 |
"""Test that certain exdates do not occur.""" |
| 30 |
events = calendars.issue_20_exdate_ignored.at(exdate[:8]) |
| 31 |
assert not events, f"{events[0].to_ical().decode()} should not occur at {exdate}." |
| 32 |
|
| 33 |
|
| 34 |
expected_dates = [ |
| 35 |
|
| 36 |
|
| 37 |
"20191029", |
| 38 |
|
| 39 |
"20191112", |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
"20191210", |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
"20200107", |
| 48 |
"20200114", |
| 49 |
"20200121", |
| 50 |
"20200128", |
| 51 |
] |
| 52 |
|
| 53 |
|
| 54 |
@pytest.mark.parametrize("date", expected_dates) |
| 55 |
def test_rrule_dates_show_up(date, calendars): |
| 56 |
"""Test that the other events are present. |
| 57 |
|
| 58 |
The exdates are commented out. |
| 59 |
""" |
| 60 |
events = calendars.issue_20_exdate_ignored.at(date) |
| 61 |
assert len(events) == 1, "There should be an event at.".format() |
| 62 |
|
| 63 |
|
| 64 |
def test_there_are_n_events(calendars): |
| 65 |
"""Test the total numer of events.""" |
| 66 |
events = list(calendars.issue_20_exdate_ignored.all()) |
| 67 |
for event, expected_date in zip(events, expected_dates): |
| 68 |
print("start: {} expected: {}".format(event["DTSTART"].dt, expected_date)) |
| 69 |
for date in expected_dates[len(events) :]: |
| 70 |
print(f"expected: {date}") |
| 71 |
for event in events[len(expected_dates) :]: |
| 72 |
print("not expected: {}".format(event["DTSTART"].dt)) |
| 73 |
assert len(events) == 7 |
| 74 |
|
| 75 |
|
| 76 |
def test_rdate_after_until_also_in_rrule(calendars): |
| 77 |
"""Special test for pytz, if the event is included.""" |
| 78 |
events = calendars.rdate_falls_on_rrule_until.at("20200204") |
| 79 |
for event in events: |
| 80 |
print(event) |
| 81 |
assert len(events) == 1 |