File: test_issue_113_period_in_rdate.py

package info (click to toggle)
python-recurring-ical-events 3.3.3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,128 kB
  • sloc: python: 2,896; sh: 15; makefile: 3
file content (45 lines) | stat: -rw-r--r-- 1,528 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""This tests that RDATE can be a PERIOD.

See https://github.com/niccokunzmann/python-recurring-ical-events/issues/113

    Value Type:  The default value type for this property is DATE-TIME.
       The value type can be set to DATE or PERIOD.

    If the "RDATE" property is
    specified as a PERIOD value the duration of the recurrence
    instance will be the one specified by the "RDATE" property, and
    not the duration of the recurrence instance defined by the
    "DTSTART" property.

"""

from datetime import datetime, timedelta

import pytz


def test_start_of_rdate(calendars):
    """The event starts on that time."""
    event = calendars.issue_113_period_in_rdate.at("20231213")[0]
    expected_start = pytz.timezone("America/Vancouver").localize(
        datetime(2023, 12, 13, 12, 0)
    )
    start = event["DTSTART"].dt
    assert start == expected_start


def test_end_of_rdate(calendars):
    """The event starts on that time."""
    event = calendars.issue_113_period_in_rdate.at("20231213")[0]
    assert event["DTEND"].dt == pytz.timezone("America/Vancouver").localize(
        datetime(2023, 12, 13, 15, 0)
    )


def test_rdate_with_a_period_with_duration(calendars):
    """Check that we can process RDATE with a duration as second value."""
    events = calendars.issue_113_period_rdate_duration.at("20240913")
    assert len(events) == 1, "We found the event with the rdate."
    event = events[0]
    duration = event["DTEND"].dt - event["DTSTART"].dt
    assert duration == timedelta(hours=2)