File: test_issue_132_swapped_start_and_end.py

package info (click to toggle)
python-recurring-ical-events 3.8.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 3,584 kB
  • sloc: python: 4,476; makefile: 84
file content (37 lines) | stat: -rw-r--r-- 1,365 bytes parent folder | download
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
"""Check that we can still compute if start and end are swapped."""

from datetime import datetime

import pytest


def test_event_case(calendars):
    """Test an event with swapped start and end."""
    event = calendars.issue_132_swapped_start_and_end.first
    assert event.start.replace(tzinfo=None) == datetime(2023, 12, 18, 23, 30)
    assert event.end.replace(tzinfo=None) == datetime(2023, 12, 18, 23, 45)


def test_todo_case(calendars):
    """Test an event with swapped start and end."""
    calendars.components = ["VTODO"]
    todo = calendars.issue_132_swapped_start_and_end.first
    print(todo)
    assert todo.start.replace(tzinfo=None) == datetime(2023, 12, 18, 23, 30)
    assert todo.end.replace(tzinfo=None) == datetime(2023, 12, 18, 23, 45)


@pytest.mark.parametrize("skip_invalid", [True, False])
def test_old_example_works_now(calendars, ZoneInfo, skip_invalid):
    """The old tests works now."""
    calendars.skip_bad_series = skip_invalid
    events = calendars.end_before_start_event.at(2019)
    print(list(calendars.end_before_start_event.all()))
    assert len(events) == 1
    event = events[0]
    assert event.start == datetime(
        2019, 3, 4, 8, tzinfo=ZoneInfo("Europe/Berlin")
    )  # 20190304T080000
    assert event.end == datetime(
        2019, 3, 4, 8, 30, tzinfo=ZoneInfo("Europe/Berlin")
    )  # 20190304T080300