File: test_issue_48_daylight.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 (40 lines) | stat: -rw-r--r-- 1,104 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
"""These tests are for Issue 48
https://github.com/niccokunzmann/python-recurring-ical-events/issues/48

These were the events occurring when the issue was raised:
    EVENT2:
    start: 2020-11-02 11:30:00+00:00
    stop:  2020-11-02 13:00:00+00:00

March to October: UTC+1
October to March: UTC+0

"""

from datetime import datetime

import pytest
from pytz import timezone

TZ = timezone("Europe/Lisbon")


@pytest.mark.parametrize(
    ("date", "event_name"),
    [
        (datetime(2020, 11, 2, 11, 15, 0, 0), 0),
        (datetime(2020, 11, 2, 11, 31, 0, 0), "EVENT2"),
        (datetime(2020, 11, 2, 12, 0, 0, 0), "EVENT2"),
        (datetime(2020, 11, 2, 12, 1, 0, 0), "EVENT2"),
        (datetime(2020, 11, 2, 12, 59, 0, 0), "EVENT2"),
        (datetime(2020, 11, 2, 13, 1, 0, 0), 0),
    ],
)
def test_event_timing(calendars, date, event_name):
    date = TZ.localize(date)
    events = calendars.issue_48_daylight_aware_repeats.at(date)
    if event_name:
        assert len(events) == 1
        assert events[0]["UID"] == event_name
    else:
        assert not events, "no events expected"