org.notification_service
Attributes
Classes
It can't hurt to abstract this Firebase notification away. |
|
Firebase implementation of the notification service. |
|
Test implementation that records calls. |
Functions
|
Get the appropriate notification service. |
|
Set a test notification service for testing purposes. |
Module Contents
- class org.notification_service.NotificationService[source]
Bases:
abc.ABC
It can’t hurt to abstract this Firebase notification away. First and foremost, this should allow for testing without mocking the wohle house
- abstractmethod send_notification(topic: str, title: str, body: str, data: dict[str, Any] | None = None) str [source]
Send a notification to a specific topic.
- Args:
topic: The topic to send to title: Notification title body: Notification body data: Additional data to include
- Returns:
str: Message ID or response
- class org.notification_service.FirebaseNotificationService(credentials_json: str)[source]
Bases:
NotificationService
Firebase implementation of the notification service.
- _get_firebase_app() Any [source]
Get or initialize the Firebase app instance.
- Returns:
The Firebase app instance.
- send_notification(topic: str, title: str, body: str, data: dict[str, Any] | None = None) str [source]
Send notification via Firebase.
- Args:
topic: Topic to send the notification to. title: The notification title. body: The notification body text. data: Optional additional data to include.
- Returns:
The message ID from Firebase.
- class org.notification_service.TestNotificationService[source]
Bases:
NotificationService
Test implementation that records calls.
- org.notification_service._TEST_NOTIFICATION_SERVICE: NotificationService | None = None[source]
- org.notification_service.get_notification_service(credentials_json: str | None = None) NotificationService [source]
Get the appropriate notification service.
In tests, returns the test service if one has been registered. In production, returns a Firebase notification service.
- Args:
credentials_json: Firebase credentials JSON for production use
- Returns:
NotificationService: The notification service implementation
- org.notification_service.set_test_notification_service(service: NotificationService | None = None) None [source]
Set a test notification service for testing purposes.
- Args:
service: The test service to use, or None to clear