mirror of
https://github.com/home-assistant/core.git
synced 2026-09-15 13:08:41 +01:00
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
"""Tests for the Bitvis Power Hub integration."""
|
|
|
|
from collections.abc import Callable
|
|
|
|
from bitvis_protobuf.listener import FilterMac
|
|
from bitvis_protobuf.parse import PayloadDiagnostic, PayloadSample
|
|
import pytest
|
|
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from tests.common import MockConfigEntry
|
|
|
|
|
|
async def setup_integration(hass: HomeAssistant, config_entry: MockConfigEntry) -> None:
|
|
"""Set up the integration."""
|
|
config_entry.add_to_hass(hass)
|
|
|
|
await hass.config_entries.async_setup(config_entry.entry_id)
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
def find_listener_callback(
|
|
listener: object,
|
|
mac_address: str,
|
|
) -> Callable[[PayloadSample | PayloadDiagnostic, tuple[str, int]], None]:
|
|
"""Find the listener callback registered for a MAC address."""
|
|
register = listener.register
|
|
for call in register.call_args_list:
|
|
filt = call[0][0]
|
|
if (
|
|
isinstance(filt, FilterMac)
|
|
and filt.mac_address.lower() == mac_address.lower()
|
|
):
|
|
return call[0][1]
|
|
pytest.fail(f"Callback for MAC {mac_address} not found")
|