mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Refactor evohome tests as per best practice (#129229)
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
This commit is contained in:
parent
d68da74790
commit
39ba4cff2f
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -9,3 +9,97 @@
|
||||
}),
|
||||
])
|
||||
# ---
|
||||
# name: test_setup_platform[botched][water_heater.domestic_hot_water-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'away_mode': 'on',
|
||||
'current_temperature': 23,
|
||||
'friendly_name': 'Domestic Hot Water',
|
||||
'icon': 'mdi:thermometer-lines',
|
||||
'max_temp': 60,
|
||||
'min_temp': 43,
|
||||
'operation_list': list([
|
||||
'auto',
|
||||
'on',
|
||||
'off',
|
||||
]),
|
||||
'operation_mode': 'off',
|
||||
'status': dict({
|
||||
'active_faults': list([
|
||||
]),
|
||||
'dhw_id': '3933910',
|
||||
'setpoints': dict({
|
||||
'next_sp_from': '2024-07-10T13:00:00+01:00',
|
||||
'next_sp_state': 'Off',
|
||||
'this_sp_from': '2024-07-10T12:00:00+01:00',
|
||||
'this_sp_state': 'On',
|
||||
}),
|
||||
'state_status': dict({
|
||||
'mode': 'PermanentOverride',
|
||||
'state': 'Off',
|
||||
}),
|
||||
'temperature_status': dict({
|
||||
'is_available': True,
|
||||
'temperature': 23.0,
|
||||
}),
|
||||
}),
|
||||
'supported_features': <WaterHeaterEntityFeature: 6>,
|
||||
'target_temp_high': None,
|
||||
'target_temp_low': None,
|
||||
'temperature': None,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'water_heater.domestic_hot_water',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_setup_platform[default][water_heater.domestic_hot_water-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'away_mode': 'on',
|
||||
'current_temperature': 23,
|
||||
'friendly_name': 'Domestic Hot Water',
|
||||
'icon': 'mdi:thermometer-lines',
|
||||
'max_temp': 60,
|
||||
'min_temp': 43,
|
||||
'operation_list': list([
|
||||
'auto',
|
||||
'on',
|
||||
'off',
|
||||
]),
|
||||
'operation_mode': 'off',
|
||||
'status': dict({
|
||||
'active_faults': list([
|
||||
]),
|
||||
'dhw_id': '3933910',
|
||||
'setpoints': dict({
|
||||
'next_sp_from': '2024-07-10T13:00:00+01:00',
|
||||
'next_sp_state': 'Off',
|
||||
'this_sp_from': '2024-07-10T12:00:00+01:00',
|
||||
'this_sp_state': 'On',
|
||||
}),
|
||||
'state_status': dict({
|
||||
'mode': 'PermanentOverride',
|
||||
'state': 'Off',
|
||||
}),
|
||||
'temperature_status': dict({
|
||||
'is_available': True,
|
||||
'temperature': 23.0,
|
||||
}),
|
||||
}),
|
||||
'supported_features': <WaterHeaterEntityFeature: 6>,
|
||||
'target_temp_high': None,
|
||||
'target_temp_low': None,
|
||||
'temperature': None,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'water_heater.domestic_hot_water',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
|
@ -1,4 +1,4 @@
|
||||
"""The tests for climate entities of evohome.
|
||||
"""The tests for the climate platform of evohome.
|
||||
|
||||
All evohome systems have controllers and at least one zone.
|
||||
"""
|
||||
@ -28,9 +28,31 @@ from homeassistant.const import (
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .conftest import setup_evohome
|
||||
from .const import TEST_INSTALLS
|
||||
|
||||
|
||||
@pytest.mark.parametrize("install", [*TEST_INSTALLS, "botched"])
|
||||
async def test_setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: dict[str, str],
|
||||
install: str,
|
||||
snapshot: SnapshotAssertion,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
) -> None:
|
||||
"""Test entities and their states after setup of evohome."""
|
||||
|
||||
# Cannot use the evohome fixture, as need to set dtm first
|
||||
# - some extended state attrs are relative the current time
|
||||
freezer.move_to("2024-07-10T12:00:00Z")
|
||||
|
||||
async for _ in setup_evohome(hass, config, install=install):
|
||||
pass
|
||||
|
||||
for x in hass.states.async_all(Platform.CLIMATE):
|
||||
assert x == snapshot(name=f"{x.entity_id}-state")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("install", TEST_INSTALLS)
|
||||
async def test_zone_set_hvac_mode(
|
||||
hass: HomeAssistant,
|
||||
|
@ -8,7 +8,6 @@ from unittest.mock import patch
|
||||
|
||||
from evohomeasync2 import EvohomeClient, exceptions as exc
|
||||
from evohomeasync2.broker import _ERR_MSG_LOOKUP_AUTH, _ERR_MSG_LOOKUP_BASE
|
||||
from freezegun.api import FrozenDateTimeFactory
|
||||
import pytest
|
||||
from syrupy import SnapshotAssertion
|
||||
|
||||
@ -16,29 +15,8 @@ from homeassistant.components.evohome import DOMAIN, EvoService
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from .conftest import setup_evohome
|
||||
from .const import TEST_INSTALLS
|
||||
|
||||
|
||||
@pytest.mark.parametrize("install", [*TEST_INSTALLS, "botched"])
|
||||
async def test_entities(
|
||||
hass: HomeAssistant,
|
||||
config: dict[str, str],
|
||||
install: str,
|
||||
snapshot: SnapshotAssertion,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
) -> None:
|
||||
"""Test entities and state after setup of a Honeywell TCC-compatible system."""
|
||||
|
||||
# some extended state attrs are relative the current time
|
||||
freezer.move_to("2024-07-10T12:00:00Z")
|
||||
|
||||
async for _ in setup_evohome(hass, config, install=install):
|
||||
pass
|
||||
|
||||
assert hass.states.async_all() == snapshot
|
||||
|
||||
|
||||
SETUP_FAILED_ANTICIPATED = (
|
||||
"homeassistant.setup",
|
||||
logging.ERROR,
|
||||
@ -148,6 +126,20 @@ async def test_client_request_failure_v2(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("install", [*TEST_INSTALLS, "botched"])
|
||||
async def test_setup(
|
||||
hass: HomeAssistant,
|
||||
evohome: EvohomeClient,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test services after setup of evohome.
|
||||
|
||||
Registered services vary by the type of system.
|
||||
"""
|
||||
|
||||
assert hass.services.async_services_for_domain(DOMAIN).keys() == snapshot
|
||||
|
||||
|
||||
@pytest.mark.parametrize("install", ["default"])
|
||||
async def test_service_refresh_system(
|
||||
hass: HomeAssistant,
|
||||
|
@ -1,4 +1,4 @@
|
||||
"""The tests for water_heater entities of evohome.
|
||||
"""The tests for the water_heater platform of evohome.
|
||||
|
||||
Not all evohome systems will have a DHW zone.
|
||||
"""
|
||||
@ -27,11 +27,33 @@ from homeassistant.const import (
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
|
||||
from .conftest import setup_evohome
|
||||
from .const import TEST_INSTALLS_WITH_DHW
|
||||
|
||||
DHW_ENTITY_ID = "water_heater.domestic_hot_water"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("install", [*TEST_INSTALLS_WITH_DHW, "botched"])
|
||||
async def test_setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: dict[str, str],
|
||||
install: str,
|
||||
snapshot: SnapshotAssertion,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
) -> None:
|
||||
"""Test entities and their states after setup of evohome."""
|
||||
|
||||
# Cannot use the evohome fixture, as need to set dtm first
|
||||
# - some extended state attrs are relative the current time
|
||||
freezer.move_to("2024-07-10T12:00:00Z")
|
||||
|
||||
async for _ in setup_evohome(hass, config, install=install):
|
||||
pass
|
||||
|
||||
for x in hass.states.async_all(Platform.WATER_HEATER):
|
||||
assert x == snapshot(name=f"{x.entity_id}-state")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("install", TEST_INSTALLS_WITH_DHW)
|
||||
async def test_set_operation_mode(
|
||||
hass: HomeAssistant,
|
||||
|
Loading…
x
Reference in New Issue
Block a user