Use fixtures in UniFi device tracker tests (#118912)

This commit is contained in:
Robert Svensson 2024-06-07 21:28:02 +02:00 committed by GitHub
parent 6c15351c18
commit 20df747806
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 636 additions and 546 deletions

View File

@ -12,6 +12,7 @@ from unittest.mock import patch
from aiounifi.models.message import MessageKey
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.hub.websocket import RETRY_TIMER
from homeassistant.config_entries import ConfigEntry
@ -111,6 +112,27 @@ def config_entry_options_fixture() -> MappingProxyType[str, Any]:
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")
def request_fixture(
aioclient_mock: AiohttpClientMocker,

File diff suppressed because it is too large Load Diff