| 1 | """From https://tools.ietf.org/html/rfc5545#section-3.8.5.2 |
| 2 | |
| 3 | Property Name: RDATE |
| 4 | |
| 5 | Purpose: This property defines the list of DATE-TIME values for |
| 6 | recurring events, to-dos, journal entries, or time zone |
| 7 | definitions. |
| 8 | |
| 9 | Value Type: The default value type for this property is DATE-TIME. |
| 10 | The value type can be set to DATE or PERIOD. |
| 11 | |
| 12 | Property Parameters: IANA, non-standard, value data type, and time |
| 13 | zone identifier property parameters can be specified on this |
| 14 | property. |
| 15 | |
| 16 | Conformance: This property can be specified in recurring "VEVENT", |
| 17 | "VTODO", and "VJOURNAL" calendar components as well as in the |
| 18 | "STANDARD" and "DAYLIGHT" sub-components of the "VTIMEZONE" |
| 19 | calendar component. |
| 20 | |
| 21 | Description: This property can appear along with the "RRULE" |
| 22 | property to define an aggregate set of repeating occurrences. |
| 23 | When they both appear in a recurring component, the recurrence |
| 24 | instances are defined by the union of occurrences defined by both |
| 25 | the "RDATE" and "RRULE". |
| 26 | |
| 27 | The recurrence dates, if specified, are used in computing the |
| 28 | recurrence set. The recurrence set is the complete set of |
| 29 | recurrence instances for a calendar component. The recurrence set |
| 30 | is generated by considering the initial "DTSTART" property along |
| 31 | with the "RRULE", "RDATE", and "EXDATE" properties contained |
| 32 | within the recurring component. The "DTSTART" property defines |
| 33 | the first instance in the recurrence set. The "DTSTART" property |
| 34 | value SHOULD match the pattern of the recurrence rule, if |
| 35 | specified. The recurrence set generated with a "DTSTART" property |
| 36 | value that doesn't match the pattern of the rule is undefined. |
| 37 | The final recurrence set is generated by gathering all of the |
| 38 | start DATE-TIME values generated by any of the specified "RRULE" |
| 39 | and "RDATE" properties, and then excluding any start DATE-TIME |
| 40 | values specified by "EXDATE" properties. This implies that start |
| 41 | DATE-TIME values specified by "EXDATE" properties take precedence |
| 42 | over those specified by inclusion properties (i.e., "RDATE" and |
| 43 | "RRULE"). Where duplicate instances are generated by the "RRULE" |
| 44 | and "RDATE" properties, only one recurrence is considered. |
| 45 | Duplicate instances are ignored. |
| 46 | """ |
| 47 | |
| 48 | import pytest |
| 49 | |
| 50 | |
| 51 | @pytest.mark.parametrize( |
| 52 | "day", |
| 53 | [ |
| 54 | "20130803", |
| 55 | "20130831", |
| 56 | "20131005", |
| 57 | "20131102", |
| 58 | "20131130", |
| 59 | "20140104", |
| 60 | "20140201", |
| 61 | "20140301", |
| 62 | "20140405", |
| 63 | "20140503", |
| 64 | "20140531", |
| 65 | "20140705", |
| 66 | ], |
| 67 | ) |
| 68 | def test_rdate_is_included(calendars, day): |
| 69 | events = calendars.rdate_hackerpublicradio.at(day) |
| 70 | assert len(events) == 1 |
| 71 | |
| 72 | |
| 73 | def test_rdate_does_not_double_rrule_entry(calendars): |
| 74 | """ |
| 75 | When the combination of the "RRULE" and "RDATE" properties in a |
| 76 | recurring component produces multiple instances having the same |
| 77 | start DATE-TIME value, they should be collapsed to, and |
| 78 | considered as, a single instance. |
| 79 | """ |
| 80 | events = calendars.rdate.at("20140705") |
| 81 | assert len(events) == 1 |
| 82 | |
| 83 | |
| 84 | def test_rdate_can_be_excluded_by_exdate(calendars): |
| 85 | events = calendars.rdate.at("20250705") |
| 86 | assert len(events) == 0 |
| 87 | |
| 88 | |
| 89 | def test_rdate_and_rrule_can_be_excluded_by_exdate(calendars): |
| 90 | events = calendars.rdate.at("20150705") |
| 91 | assert len(events) == 0 |
| 92 | |
| 93 | |
| 94 | def test_rdate_occurs_multiple_times(calendars): |
| 95 | """An event can not only have an RDATE once but also many of them.""" |
| 96 | events = list(calendars.rdate_hackerpublicradio.all()) |
| 97 | assert len(events) == 12 |