File: test_repetitions_do_not_change.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 (43 lines) | stat: -rw-r--r-- 1,311 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
"""The objective of this test is to ensure that repeated events can be copied
into an ICAL calendar again without multiplying themselves to wrong dates.
"""

import recurring_ical_events


def assert_event_does_not_duplicate(event):
    for i, _ in enumerate(recurring_ical_events.of(event).all()):
        assert i <= 1, event


def assert_events_do_not_duplicate(events):
    assert events
    for event in events:
        assert_event_does_not_duplicate(event)


def test_simple_event(calendars):
    """An event with no repetitions."""
    assert_events_do_not_duplicate(calendars.duration.at(2018))


def test_rdate_event(calendars):
    """An event with rdate."""
    assert_events_do_not_duplicate(calendars.rdate_hackerpublicradio.all())


def test_rrule(calendars):
    """An event with rrule and a number of events."""
    assert_events_do_not_duplicate(calendars.event_10_times.at(2020))


def test_rrule_with_exdate(calendars):
    """An event with rrule and exrule."""
    assert_events_do_not_duplicate(calendars.each_week_but_two_deleted.at(2019))


def test_exdate_is_removed_because_it_is_not_needed(calendars):
    """A repeated event removed RDATE and RRULE and as such should
    also remove the EXDATE values."""
    for event in calendars.rdate.all():
        assert "EXDATE" not in event