Skip to content

Commit

Permalink
Use fixtures in UniFi device tracker tests (home-assistant#118912)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kane610 authored Jun 7, 2024
1 parent 6c15351 commit 20df747
Show file tree
Hide file tree
Showing 2 changed files with 638 additions and 548 deletions.
22 changes: 22 additions & 0 deletions tests/components/unifi/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
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
Expand Down Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 20df747

Please sign in to comment.