1
0
mirror of https://github.com/home-assistant/core.git synced 2026-05-20 07:20:14 +01:00

Improve test structure for Overkiz (#168728)

This commit is contained in:
Mick Vleeshouwer
2026-04-22 10:10:18 +02:00
committed by GitHub
parent 9b2a81614f
commit 598be31daf
5 changed files with 17 additions and 28 deletions
+9
View File
@@ -2,6 +2,7 @@
from collections.abc import Awaitable, Callable, Generator
from dataclasses import dataclass, field
from typing import NamedTuple
from unittest.mock import AsyncMock, patch
from pyoverkiz.client import OverkizClient
@@ -20,6 +21,14 @@ from tests.common import MockConfigEntry
type SetupOverkizIntegration = Callable[..., Awaitable[MockConfigEntry]]
class FixtureDevice(NamedTuple):
"""Test device binding a fixture file to a device URL and entity id."""
fixture: str
device_url: str
entity_id: str
@dataclass
class MockOverkizClient(OverkizClient):
"""Mock Overkiz client used by integration tests."""
+2 -11
View File
@@ -4,7 +4,7 @@ from __future__ import annotations
from collections.abc import Generator
from pathlib import Path
from typing import Any, NamedTuple
from typing import Any
from unittest.mock import patch
from freezegun.api import FrozenDateTimeFactory
@@ -33,20 +33,11 @@ from homeassistant.const import ATTR_ENTITY_ID, STATE_UNAVAILABLE, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from .conftest import MockOverkizClient, SetupOverkizIntegration
from .conftest import FixtureDevice, MockOverkizClient, SetupOverkizIntegration
from .helpers import assert_command_call, async_deliver_events, build_event
from tests.common import snapshot_platform
class FixtureDevice(NamedTuple):
"""Test device binding a fixture file to a device URL and entity id."""
fixture: str
device_url: str
entity_id: str
AWNING = FixtureDevice(
"setup/local_somfy_connexoon_europe.json",
"io://1234-1234-1234/5928357",
+3 -4
View File
@@ -24,7 +24,7 @@ async def test_diagnostics(
) -> None:
"""Test diagnostics."""
diagnostic_data = await async_load_json_object_fixture(
hass, "setup/setup_tahoma_switch.json", DOMAIN
hass, "diagnostics/cloud_somfy_tahoma_switch_europe.json", DOMAIN
)
with patch.multiple(
@@ -47,7 +47,7 @@ async def test_device_diagnostics(
) -> None:
"""Test device diagnostics."""
diagnostic_data = await async_load_json_object_fixture(
hass, "setup/setup_tahoma_switch.json", DOMAIN
hass, "diagnostics/cloud_somfy_tahoma_switch_europe.json", DOMAIN
)
device = device_registry.async_get_device(
@@ -75,9 +75,8 @@ async def test_device_diagnostics_execution_history_subsystem(
device_registry: dr.DeviceRegistry,
) -> None:
"""Test execution history matching ignores subsystem suffix."""
diagnostic_data = await async_load_json_object_fixture(
hass, "setup/setup_tahoma_switch.json", DOMAIN
hass, "diagnostics/cloud_somfy_tahoma_switch_europe.json", DOMAIN
)
device = device_registry.async_get_device(
+3 -13
View File
@@ -4,7 +4,6 @@ from __future__ import annotations
from collections.abc import Generator
from pathlib import Path
from typing import NamedTuple
from unittest.mock import patch
from freezegun.api import FrozenDateTimeFactory
@@ -16,20 +15,11 @@ from homeassistant.const import STATE_UNAVAILABLE, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from .conftest import MockOverkizClient, SetupOverkizIntegration
from .conftest import FixtureDevice, MockOverkizClient, SetupOverkizIntegration
from .helpers import async_deliver_events, build_event
from tests.common import snapshot_platform
class FixtureDevice(NamedTuple):
"""Test device binding a fixture file to a device URL and entity id."""
fixture: str
device_url: str
entity_id: str
TEMPERATURE_SENSOR = FixtureDevice(
"setup/cloud_nexity_rail_din_europe.json",
"io://1234-5678-1698/15702199#2",
@@ -53,8 +43,8 @@ HOMEKIT_STACK = FixtureDevice(
# Device with core:MeasuredValueType attribute (test for dynamic unit resolution)
COZYTOUCH_DHW = FixtureDevice(
"setup/cloud_atlantic_cozytouch.json",
"io://1234-5678-5643/109286#1",
"sensor.patio_water_heating_temperature",
"io://1234-5678-5643/109286#2",
"sensor.patio_water_heating_office_energy_meter_electric_energy_consumption",
)
SNAPSHOT_FIXTURES = [