| 1 | """Test that some attributes of the calendar objects |
| 2 | are kept if required. |
| 3 | |
| 4 | See Issue 23 https://github.com/niccokunzmann/python-recurring-ical-events/issues/23. |
| 5 | """ |
| 6 | |
| 7 | import pytest |
| 8 | |
| 9 | from recurring_ical_events import of |
| 10 | |
| 11 | RRULE = b"FREQ=DAILY;UNTIL=20160320T030000Z" |
| 12 | RDATE = b"20150705T190000Z" |
| 13 | EXDATE = b"20150705T190000Z" |
| 14 | |
| 15 | |
| 16 | class Default: |
| 17 | @staticmethod |
| 18 | def to_ical(): |
| 19 | return None |
| 20 | |
| 21 | |
| 22 | @pytest.mark.parametrize( |
| 23 | ("keywords", "rrule", "rdate", "exdate"), |
| 24 | [ |
| 25 | ({}, None, None, None), |
| 26 | ({"keep_recurrence_attributes": False}, None, None, None), |
| 27 | ({"keep_recurrence_attributes": True}, RRULE, RDATE, EXDATE), |
| 28 | ], |
| 29 | ) |
| 30 | def test_keep_recurrence_attributes_default(calendars, keywords, rrule, rdate, exdate): |
| 31 | calendar = calendars.raw.rdate2 |
| 32 | rcalendar = of(calendar, **keywords) |
| 33 | events = rcalendar.at(2014) |
| 34 | assert events |
| 35 | for event in events: |
| 36 | assert event.get("RRULE", Default).to_ical() == rrule |
| 37 | assert event.get("RDATE", Default).to_ical() == rdate |
| 38 | assert event.get("EXDATE", Default).to_ical() == exdate |