Coverage for youversion/models/events.py: 100%
49 statements
« prev ^ index » next coverage.py v7.14.3, created at 2026-06-26 11:31 +0100
« prev ^ index » next coverage.py v7.14.3, created at 2026-06-26 11:31 +0100
1"""Events and church finder data models."""
3from datetime import datetime
4from typing import Any, Protocol
6try:
7 from typing import TypeAlias
8except ImportError:
9 # Python < 3.10 compatibility
10 from typing import TypeAlias
13class EventLocationProtocol(Protocol):
14 """Protocol for event location information."""
16 name: str
17 address: str | None
18 city: str | None
19 state: str | None
20 country: str | None
21 latitude: float | None
22 longitude: float | None
24 def __getattr__(self, name: str) -> Any:
25 """Allow access to dynamically added fields."""
26 class_name = self.__class__.__name__
27 raise AttributeError(f"'{class_name}' has no attribute '{name}'")
30# Type alias for convenience
31EventLocation: TypeAlias = EventLocationProtocol
34class EventTimeProtocol(Protocol):
35 """Protocol for event time information."""
37 start_time: datetime | None
38 end_time: datetime | None
39 timezone: str | None
40 recurring: str | None
42 def __getattr__(self, name: str) -> Any:
43 """Allow access to dynamically added fields."""
44 class_name = self.__class__.__name__
45 raise AttributeError(f"'{class_name}' has no attribute '{name}'")
48# Type alias for convenience
49EventTime: TypeAlias = EventTimeProtocol
52class EventContentProtocol(Protocol):
53 """Protocol for event content information."""
55 title: str
56 description: str | None
57 image_url: str | None
58 website_url: str | None
60 def __getattr__(self, name: str) -> Any:
61 """Allow access to dynamically added fields."""
62 class_name = self.__class__.__name__
63 raise AttributeError(f"'{class_name}' has no attribute '{name}'")
66# Type alias for convenience
67EventContent: TypeAlias = EventContentProtocol
70class EventProtocol(Protocol):
71 """Protocol for event information."""
73 id: int
74 content: EventContent
75 location: EventLocation
76 time: EventTime
77 created_dt: datetime | None
78 updated_dt: datetime | None
80 def __getattr__(self, name: str) -> Any:
81 """Allow access to dynamically added fields."""
82 class_name = self.__class__.__name__
83 raise AttributeError(f"'{class_name}' has no attribute '{name}'")
86# Type alias for convenience
87Event: TypeAlias = EventProtocol
90class SavedEventProtocol(Protocol):
91 """Protocol for saved event information."""
93 event: Event
94 saved_dt: datetime | None
95 comments: dict[str, Any] | None
97 def __getattr__(self, name: str) -> Any:
98 """Allow access to dynamically added fields."""
99 class_name = self.__class__.__name__
100 raise AttributeError(f"'{class_name}' has no attribute '{name}'")
103# Type alias for convenience
104SavedEvent: TypeAlias = SavedEventProtocol
107class SavedEventsProtocol(Protocol):
108 """Protocol for saved events list."""
110 events: list[SavedEvent]
111 total: int
113 def __getattr__(self, name: str) -> Any:
114 """Allow access to dynamically added fields."""
115 class_name = self.__class__.__name__
116 raise AttributeError(f"'{class_name}' has no attribute '{name}'")
119# Type alias for convenience
120SavedEvents: TypeAlias = SavedEventsProtocol
123class SearchEventProtocol(Protocol):
124 """Protocol for search event result."""
126 event: Event
127 distance: float | None
128 relevance_score: float | None
130 def __getattr__(self, name: str) -> Any:
131 """Allow access to dynamically added fields."""
132 class_name = self.__class__.__name__
133 raise AttributeError(f"'{class_name}' has no attribute '{name}'")
136# Type alias for convenience
137SearchEvent: TypeAlias = SearchEventProtocol
140class SearchEventsProtocol(Protocol):
141 """Protocol for search events results."""
143 events: list[SearchEvent]
144 total: int
145 query: str | None
147 def __getattr__(self, name: str) -> Any:
148 """Allow access to dynamically added fields."""
149 class_name = self.__class__.__name__
150 raise AttributeError(f"'{class_name}' has no attribute '{name}'")
153# Type alias for convenience
154SearchEvents: TypeAlias = SearchEventsProtocol
157class EventConfigurationProtocol(Protocol):
158 """Protocol for event configuration."""
160 categories: list[dict[str, Any]]
161 filters: list[dict[str, Any]]
162 sort_options: list[dict[str, Any]]
164 def __getattr__(self, name: str) -> Any:
165 """Allow access to dynamically added fields."""
166 class_name = self.__class__.__name__
167 raise AttributeError(f"'{class_name}' has no attribute '{name}'")
170# Type alias for convenience
171EventConfiguration: TypeAlias = EventConfigurationProtocol