2024-08-20 08:44:06 +00:00
|
|
|
"""Tests for the SMLIGHT Zigbee adapter integration."""
|
2024-09-20 10:40:50 +00:00
|
|
|
|
|
|
|
from collections.abc import Callable
|
|
|
|
from unittest.mock import MagicMock
|
|
|
|
|
|
|
|
from pysmlight.const import Events as SmEvents
|
|
|
|
from pysmlight.sse import MessageEvent
|
|
|
|
|
|
|
|
|
|
|
|
def get_mock_event_function(
|
|
|
|
mock: MagicMock, event: SmEvents
|
|
|
|
) -> Callable[[MessageEvent], None]:
|
|
|
|
"""Extract event function from mock call_args."""
|
|
|
|
return next(
|
|
|
|
(
|
|
|
|
call_args[0][1]
|
|
|
|
for call_args in mock.sse.register_callback.call_args_list
|
|
|
|
if call_args[0][0] == event
|
|
|
|
),
|
|
|
|
None,
|
|
|
|
)
|