Debian Codegraph @

recurring_ical_events/test/test_issue_7_datetime_and_date_start_stop.py

raw symbols SCIP
1 """
2 This file contains the test cases which test that the
3 event uses the right class: date or datetime.
4 See https://github.com/niccokunzmann/python-recurring-ical-events/issues/7
5 """
6
7 import datetime
8
9 import pytest
10 from icalendar import Event
11
12
13 def test_can_serialize(calendars):
14 """Test that the event can be serialized."""
15 event = next(calendars.one_day_event.all())
16 string = event.to_ical()
17 assert isinstance(string, bytes)
18
19
20 @pytest.mark.parametrize(
21 ("attribute", "dt_type", "event_name"),
22 [
23 ("dtstart", datetime.date, "one_day_event"),
24 ("dtend", datetime.date, "one_day_event"),
25 ("dtstart", datetime.datetime, "one_event"),
26 ("dtend", datetime.datetime, "one_event"),
27 ],
28 )
29 def test_is_date(calendars, attribute, dt_type, event_name):
30 """Check the type of the attributes"""
31 event = next(calendars[event_name].all())
32 event = Event.from_ical(event.to_ical())
33 dt = event[attribute]
34 assert isinstance(dt.dt, dt_type), "content of ical should match"