Test start and end

pull/845/head
Nicco Kunzmann 2025-05-17 22:02:15 +01:00
rodzic 539123c8c4
commit 95afa99c6c
4 zmienionych plików z 57 dodań i 2 usunięć

Wyświetl plik

@ -260,6 +260,8 @@ class Event(Component):
description: Optional[str] = None,
dtstamp: Optional[date] = None,
uid: Optional[str | uuid.UUID] = None,
start: Optional[date | datetime] = None,
end: Optional[date | datetime] = None,
):
"""Create a new event with all required properties.
@ -269,6 +271,8 @@ class Event(Component):
event.summary = summary
event.description = description
event.uid = uid if uid is not None else uuid.uuid4()
event.start = start
event.end = end
return event

Wyświetl plik

@ -146,6 +146,7 @@ class Journal(Component):
description: Optional[str | Sequence[str]] = None,
dtstamp: Optional[date] = None,
uid: Optional[str | uuid.UUID] = None,
start: Optional[date | datetime] = None,
):
"""Create a new journal entry with all required properties.
@ -157,6 +158,7 @@ class Journal(Component):
journal.summary = summary
journal.descriptions = description
journal.uid = uid if uid is not None else uuid.uuid4()
journal.start = start
return journal

Wyświetl plik

@ -237,6 +237,8 @@ class Todo(Component):
description: Optional[str] = None,
dtstamp: Optional[date] = None,
uid: Optional[str | uuid.UUID] = None,
start: Optional[date | datetime] = None,
end: Optional[date | datetime] = None,
):
"""Create a new TODO with all required properties.
@ -246,6 +248,8 @@ class Todo(Component):
todo.summary = summary
todo.description = description
todo.uid = uid if uid is not None else uuid.uuid4()
todo.start = start
todo.end = end
return todo

Wyświetl plik

@ -226,6 +226,7 @@ COMPONENTS_UID = {Event, Todo, Journal, Alarm, Calendar}
(
"component_classes",
"property_name",
"key",
"initial_value",
"expected_value",
"key_present",
@ -235,6 +236,7 @@ COMPONENTS_UID = {Event, Todo, Journal, Alarm, Calendar}
(
COMPONENTS_DTSTAMP,
"DTSTAMP",
"DTSTAMP",
date(2023, 10, 21),
datetime(2023, 10, 21, tzinfo=timezone.utc),
True,
@ -243,6 +245,7 @@ COMPONENTS_UID = {Event, Todo, Journal, Alarm, Calendar}
(
COMPONENTS_DTSTAMP,
"DTSTAMP",
"DTSTAMP",
datetime(2023, 10, 22),
datetime(2023, 10, 22, tzinfo=timezone.utc),
True,
@ -251,6 +254,7 @@ COMPONENTS_UID = {Event, Todo, Journal, Alarm, Calendar}
(
COMPONENTS_DTSTAMP,
"DTSTAMP",
"DTSTAMP",
datetime(2023, 10, 23, 12, 30, tzinfo=timezone.utc),
datetime(2023, 10, 23, 12, 30, tzinfo=ZoneInfo("UTC")),
True,
@ -259,6 +263,7 @@ COMPONENTS_UID = {Event, Todo, Journal, Alarm, Calendar}
(
COMPONENTS_DTSTAMP,
"DTSTAMP",
"DTSTAMP",
datetime(2023, 10, 24, 21, 0, 1, tzinfo=timezone(timedelta(hours=1))),
datetime(2023, 10, 24, 20, 0, 1, tzinfo=ZoneInfo("UTC")),
True,
@ -267,6 +272,7 @@ COMPONENTS_UID = {Event, Todo, Journal, Alarm, Calendar}
(
COMPONENTS_DTSTAMP_AUTOMATIC,
"DTSTAMP",
"DTSTAMP",
None,
NOW_UTC,
True,
@ -275,15 +281,25 @@ COMPONENTS_UID = {Event, Todo, Journal, Alarm, Calendar}
(
COMPONENTS_DTSTAMP - COMPONENTS_DTSTAMP_AUTOMATIC,
"DTSTAMP",
"DTSTAMP",
None,
None,
False,
"DTSTAMP is not automatically set",
),
(COMPONENTS_UID, "uid", "test UID", "test UID", True, "Set the UID property"),
(
COMPONENTS_UID,
"uid",
"uid",
"test UID",
"test UID",
True,
"Set the UID property",
),
(
COMPONENTS_UID_AUTOMATIC,
"uid",
"uid",
None,
UID_DEFAULT,
True,
@ -292,11 +308,39 @@ COMPONENTS_UID = {Event, Todo, Journal, Alarm, Calendar}
(
COMPONENTS_UID - COMPONENTS_UID_AUTOMATIC,
"uid",
"uid",
None,
"",
False,
"UID is not automatically set",
),
(
{Event, Todo, Journal}, # TODO: FreeBusy
"start",
"dtstart",
datetime(2023, 10, 24, 21, 0, 1, tzinfo=ZoneInfo("Europe/Berlin")),
datetime(2023, 10, 24, 21, 0, 1, tzinfo=ZoneInfo("Europe/Berlin")),
True,
"set the start",
),
(
{Event}, # TODO: FreeBusy
"end",
"dtend",
datetime(2023, 10, 24, 22, 0, 1, tzinfo=ZoneInfo("Europe/Berlin")),
datetime(2023, 10, 24, 22, 0, 1, tzinfo=ZoneInfo("Europe/Berlin")),
True,
"set the end",
),
(
{Todo},
"end",
"due",
datetime(2023, 10, 24, 22, 0, 1, tzinfo=ZoneInfo("Europe/Berlin")),
datetime(2023, 10, 24, 22, 0, 1, tzinfo=ZoneInfo("Europe/Berlin")),
True,
"set the end",
),
],
)
@pytest.mark.parametrize(
@ -309,6 +353,7 @@ def test_dtstamp_becomes_utc(
initial_value,
expected_value,
key_present,
key,
message,
):
"""We set and get the dtstamp."""
@ -325,4 +370,4 @@ def test_dtstamp_becomes_utc(
assert_component_attribute_has_value(
component, property_name, expected_value, message
)
assert (property_name in component) == key_present, message
assert (key in component) == key_present, message