forked from home-assistant/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor smlight event_function to common function (home-assistant#12…
…6260) refactor event_function
- Loading branch information
Showing
3 changed files
with
28 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,21 @@ | ||
"""Tests for the SMLIGHT Zigbee adapter integration.""" | ||
|
||
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, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters