File: test_issue_27.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 (39 lines) | stat: -rw-r--r-- 1,245 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
"""These tests are for Issue 27
https://github.com/niccokunzmann/python-recurring-ical-events/issues/27
https://github.com/niccokunzmann/python-recurring-ical-events/pull/32

Diff of the two files:

diff test/calendars/issue-27-t1.ics test/calendars/issue-27-t2.ics

    < RRULE:FREQ=DAILY;UNTIL=20200429T000000
    < EXDATE:20200427T120000Z
    ---
    > RRULE:FREQ=DAILY;UNTIL=20200429T000000Z
    > EXDATE:20200427T140000Z

"""

start_date = (2020, 4, 25)
end_date = (2020, 4, 30)


def print_events(events):
    for event in events:
        start = event["DTSTART"].dt
        duration = event["DTEND"].dt - event["DTSTART"].dt
        print(f"start {start} duration {duration}")


def test_until_value_with_UNKNOWN_timezone_works_with_exdate(calendars):
    """The until value has no time zone attached."""
    events = calendars.issue_27_t1.between(start_date, end_date)
    print_events(events)
    assert len(events) == 2, "two events, exdate matches one"


def test_until_value_with_DEFAULT_timezone_works_with_exdate(calendars):
    """The until value uses the default time zone."""
    events = calendars.issue_27_t2.between(start_date, end_date)
    print_events(events)
    assert len(events) == 2, "two events, exdate matches one"