Debian Codegraph @

recurring_ical_events/test/test_issue_113_period_in_rdate.py

raw symbols SCIP
1 """This tests that RDATE can be a PERIOD.
2
3 See https://github.com/niccokunzmann/python-recurring-ical-events/issues/113
4
5 Value Type: The default value type for this property is DATE-TIME.
6 The value type can be set to DATE or PERIOD.
7
8 If the "RDATE" property is
9 specified as a PERIOD value the duration of the recurrence
10 instance will be the one specified by the "RDATE" property, and
11 not the duration of the recurrence instance defined by the
12 "DTSTART" property.
13
14 """
15
16 from datetime import datetime, timedelta
17
18 import pytz
19
20
21 def test_start_of_rdate(calendars):
22 """The event starts on that time."""
23 event = calendars.issue_113_period_in_rdate.at("20231213")[0]
24 expected_start = pytz.timezone("America/Vancouver").localize(
25 datetime(2023, 12, 13, 12, 0)
26 )
27 start = event["DTSTART"].dt
28 assert start == expected_start
29
30
31 def test_end_of_rdate(calendars):
32 """The event starts on that time."""
33 event = calendars.issue_113_period_in_rdate.at("20231213")[0]
34 assert event["DTEND"].dt == pytz.timezone("America/Vancouver").localize(
35 datetime(2023, 12, 13, 15, 0)
36 )
37
38
39 def test_rdate_with_a_period_with_duration(calendars):
40 """Check that we can process RDATE with a duration as second value."""
41 events = calendars.issue_113_period_rdate_duration.at("20240913")
42 assert len(events) == 1, "We found the event with the rdate."
43 event = events[0]
44 duration = event["DTEND"].dt - event["DTSTART"].dt
45 assert duration == timedelta(hours=2)