Skip to content

Commit

Permalink
Add first tests for calendar alarms
Browse files Browse the repository at this point in the history
  • Loading branch information
niccokunzmann committed Oct 2, 2024
1 parent db2f8b6 commit 113ff9b
Show file tree
Hide file tree
Showing 8 changed files with 2,725 additions and 2 deletions.
23 changes: 22 additions & 1 deletion recurring_ical_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,18 @@ def end(self) -> Time:
return self.start


class AlarmAdapter(ComponentAdapter):
"""Adapter for alarms.
The "VALARM" calendar component MUST only appear within either a
"VEVENT" or "VTODO" calendar component. - RFC 5545
"""

@staticmethod
def component_name() -> str:
"""The icalendar component name."""
return "VALARM"

class Occurrence:
"""A repetition of an event."""

Expand Down Expand Up @@ -1129,7 +1141,7 @@ class ComponentsWithName(SelectComponents):
- composition to combine collection behavior (see AllKnownComponents)
"""

component_adapters = [EventAdapter, TodoAdapter, JournalAdapter]
component_adapters = [EventAdapter, TodoAdapter, JournalAdapter, AlarmAdapter]

@cached_property
def _component_adapters(self) -> dict[str : type[ComponentAdapter]]:
Expand Down Expand Up @@ -1420,6 +1432,15 @@ def count(self) -> int:
i += 1
return i

@property
def first(self) -> Component:
"""Return the first recurring component in this calendar.
If there is no recurring component, an IndexError is raised.
"""
for component in self.all():
return component
raise IndexError("No components found.")

def of(
a_calendar: Component,
Expand Down
Loading

0 comments on commit 113ff9b

Please sign in to comment.