mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
Use fixtures in UniFi device tracker tests (#118912)
This commit is contained in:
parent
6c15351c18
commit
20df747806
@ -12,6 +12,7 @@ from unittest.mock import patch
|
|||||||
from aiounifi.models.message import MessageKey
|
from aiounifi.models.message import MessageKey
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from homeassistant.components.unifi import STORAGE_KEY, STORAGE_VERSION
|
||||||
from homeassistant.components.unifi.const import CONF_SITE_ID, DOMAIN as UNIFI_DOMAIN
|
from homeassistant.components.unifi.const import CONF_SITE_ID, DOMAIN as UNIFI_DOMAIN
|
||||||
from homeassistant.components.unifi.hub.websocket import RETRY_TIMER
|
from homeassistant.components.unifi.hub.websocket import RETRY_TIMER
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
@ -111,6 +112,27 @@ def config_entry_options_fixture() -> MappingProxyType[str, Any]:
|
|||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
||||||
|
# Known wireless clients
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(name="known_wireless_clients")
|
||||||
|
def known_wireless_clients_fixture() -> list[str]:
|
||||||
|
"""Known previously observed wireless clients."""
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(autouse=True)
|
||||||
|
def mock_wireless_client_storage(hass_storage, known_wireless_clients: list[str]):
|
||||||
|
"""Mock the known wireless storage."""
|
||||||
|
data: dict[str, list[str]] = (
|
||||||
|
{"wireless_clients": known_wireless_clients} if known_wireless_clients else {}
|
||||||
|
)
|
||||||
|
hass_storage[STORAGE_KEY] = {"version": STORAGE_VERSION, "data": data}
|
||||||
|
|
||||||
|
|
||||||
|
# UniFi request mocks
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="mock_requests")
|
@pytest.fixture(name="mock_requests")
|
||||||
def request_fixture(
|
def request_fixture(
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user