Coverage for custom_components/supernotify/transports/persistent.py: 58%
26 statements
« prev ^ index » next coverage.py v7.10.6, created at 2026-01-07 15:35 +0000
« prev ^ index » next coverage.py v7.10.6, created at 2026-01-07 15:35 +0000
1import logging
2from typing import Any
4from custom_components.supernotify import (
5 ATTR_NOTIFICATION_ID,
6 TRANSPORT_PERSISTENT,
7)
8from custom_components.supernotify.envelope import Envelope
9from custom_components.supernotify.model import DebugTrace, TargetRequired, TransportConfig, TransportFeature
10from custom_components.supernotify.transport import Transport
12_LOGGER = logging.getLogger(__name__)
15class PersistentTransport(Transport):
16 name = TRANSPORT_PERSISTENT
18 def __init__(self, *args: Any, **kwargs: Any) -> None:
19 super().__init__(*args, **kwargs)
21 @property
22 def supported_features(self) -> TransportFeature:
23 return TransportFeature.MESSAGE | TransportFeature.TITLE
25 @property
26 def default_config(self) -> TransportConfig:
27 config = TransportConfig()
28 config.delivery_defaults.action = "persistent_notification.create"
29 config.delivery_defaults.target_required = TargetRequired.NEVER
30 return config
32 async def deliver(self, envelope: Envelope, debug_trace: DebugTrace | None = None) -> bool: # noqa: ARG002
33 data = envelope.data or {}
35 notification_id = data.get(ATTR_NOTIFICATION_ID) or envelope.delivery.data.get(ATTR_NOTIFICATION_ID)
36 action_data = envelope.core_action_data()
37 action_data["notification_id"] = notification_id
39 return await self.call_action(envelope, action_data=action_data)