mirror of
https://github.com/home-assistant/core.git
synced 2025-08-02 18:18:21 +00:00
Improve Tado water heater tests (#149806)
This commit is contained in:
parent
37579440e6
commit
506431c75f
139
tests/components/tado/snapshots/test_water_heater.ambr
Normal file
139
tests/components/tado/snapshots/test_water_heater.ambr
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
# serializer version: 1
|
||||||
|
# name: test_entities[water_heater.second_water_heater-entry]
|
||||||
|
EntityRegistryEntrySnapshot({
|
||||||
|
'aliases': set({
|
||||||
|
}),
|
||||||
|
'area_id': None,
|
||||||
|
'capabilities': dict({
|
||||||
|
'max_temp': 31.0,
|
||||||
|
'min_temp': 16.0,
|
||||||
|
'operation_list': list([
|
||||||
|
'auto',
|
||||||
|
'heat',
|
||||||
|
'off',
|
||||||
|
]),
|
||||||
|
}),
|
||||||
|
'config_entry_id': <ANY>,
|
||||||
|
'config_subentry_id': <ANY>,
|
||||||
|
'device_class': None,
|
||||||
|
'device_id': <ANY>,
|
||||||
|
'disabled_by': None,
|
||||||
|
'domain': 'water_heater',
|
||||||
|
'entity_category': None,
|
||||||
|
'entity_id': 'water_heater.second_water_heater',
|
||||||
|
'has_entity_name': True,
|
||||||
|
'hidden_by': None,
|
||||||
|
'icon': None,
|
||||||
|
'id': <ANY>,
|
||||||
|
'labels': set({
|
||||||
|
}),
|
||||||
|
'name': None,
|
||||||
|
'options': dict({
|
||||||
|
}),
|
||||||
|
'original_device_class': None,
|
||||||
|
'original_icon': None,
|
||||||
|
'original_name': None,
|
||||||
|
'platform': 'tado',
|
||||||
|
'previous_unique_id': None,
|
||||||
|
'suggested_object_id': None,
|
||||||
|
'supported_features': <WaterHeaterEntityFeature: 3>,
|
||||||
|
'translation_key': None,
|
||||||
|
'unique_id': '4 1',
|
||||||
|
'unit_of_measurement': None,
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_entities[water_heater.second_water_heater-state]
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'current_temperature': None,
|
||||||
|
'friendly_name': 'Second Water Heater',
|
||||||
|
'max_temp': 31.0,
|
||||||
|
'min_temp': 16.0,
|
||||||
|
'operation_list': list([
|
||||||
|
'auto',
|
||||||
|
'heat',
|
||||||
|
'off',
|
||||||
|
]),
|
||||||
|
'operation_mode': 'heat',
|
||||||
|
'supported_features': <WaterHeaterEntityFeature: 3>,
|
||||||
|
'target_temp_high': None,
|
||||||
|
'target_temp_low': None,
|
||||||
|
'temperature': 30.0,
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'water_heater.second_water_heater',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_reported': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': 'heat',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_entities[water_heater.water_heater-entry]
|
||||||
|
EntityRegistryEntrySnapshot({
|
||||||
|
'aliases': set({
|
||||||
|
}),
|
||||||
|
'area_id': None,
|
||||||
|
'capabilities': dict({
|
||||||
|
'max_temp': 31.0,
|
||||||
|
'min_temp': 16.0,
|
||||||
|
'operation_list': list([
|
||||||
|
'auto',
|
||||||
|
'heat',
|
||||||
|
'off',
|
||||||
|
]),
|
||||||
|
}),
|
||||||
|
'config_entry_id': <ANY>,
|
||||||
|
'config_subentry_id': <ANY>,
|
||||||
|
'device_class': None,
|
||||||
|
'device_id': <ANY>,
|
||||||
|
'disabled_by': None,
|
||||||
|
'domain': 'water_heater',
|
||||||
|
'entity_category': None,
|
||||||
|
'entity_id': 'water_heater.water_heater',
|
||||||
|
'has_entity_name': True,
|
||||||
|
'hidden_by': None,
|
||||||
|
'icon': None,
|
||||||
|
'id': <ANY>,
|
||||||
|
'labels': set({
|
||||||
|
}),
|
||||||
|
'name': None,
|
||||||
|
'options': dict({
|
||||||
|
}),
|
||||||
|
'original_device_class': None,
|
||||||
|
'original_icon': None,
|
||||||
|
'original_name': None,
|
||||||
|
'platform': 'tado',
|
||||||
|
'previous_unique_id': None,
|
||||||
|
'suggested_object_id': None,
|
||||||
|
'supported_features': <WaterHeaterEntityFeature: 3>,
|
||||||
|
'translation_key': None,
|
||||||
|
'unique_id': '2 1',
|
||||||
|
'unit_of_measurement': None,
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_entities[water_heater.water_heater-state]
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'current_temperature': None,
|
||||||
|
'friendly_name': 'Water Heater',
|
||||||
|
'max_temp': 31.0,
|
||||||
|
'min_temp': 16.0,
|
||||||
|
'operation_list': list([
|
||||||
|
'auto',
|
||||||
|
'heat',
|
||||||
|
'off',
|
||||||
|
]),
|
||||||
|
'operation_mode': 'auto',
|
||||||
|
'supported_features': <WaterHeaterEntityFeature: 3>,
|
||||||
|
'target_temp_high': None,
|
||||||
|
'target_temp_low': None,
|
||||||
|
'temperature': 65.0,
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'water_heater.water_heater',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_reported': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': 'auto',
|
||||||
|
})
|
||||||
|
# ---
|
@ -1,49 +1,35 @@
|
|||||||
"""The sensor tests for the tado platform."""
|
"""The water heater tests for the tado platform."""
|
||||||
|
|
||||||
|
from collections.abc import AsyncGenerator
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from syrupy.assertion import SnapshotAssertion
|
||||||
|
|
||||||
|
from homeassistant.components.tado import DOMAIN
|
||||||
|
from homeassistant.const import Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers import entity_registry as er
|
||||||
|
|
||||||
from .util import async_init_integration
|
from .util import async_init_integration
|
||||||
|
|
||||||
|
from tests.common import MockConfigEntry, snapshot_platform
|
||||||
|
|
||||||
async def test_water_heater_create_sensors(hass: HomeAssistant) -> None:
|
|
||||||
|
@pytest.fixture(autouse=True)
|
||||||
|
def setup_platforms() -> AsyncGenerator[None]:
|
||||||
|
"""Set up the platforms for the tests."""
|
||||||
|
with patch("homeassistant.components.tado.PLATFORMS", [Platform.WATER_HEATER]):
|
||||||
|
yield
|
||||||
|
|
||||||
|
|
||||||
|
async def test_entities(
|
||||||
|
hass: HomeAssistant, entity_registry: er.EntityRegistry, snapshot: SnapshotAssertion
|
||||||
|
) -> None:
|
||||||
"""Test creation of water heater."""
|
"""Test creation of water heater."""
|
||||||
|
|
||||||
await async_init_integration(hass)
|
await async_init_integration(hass)
|
||||||
|
|
||||||
state = hass.states.get("water_heater.water_heater")
|
config_entry: MockConfigEntry = hass.config_entries.async_entries(DOMAIN)[0]
|
||||||
assert state.state == "auto"
|
|
||||||
|
|
||||||
expected_attributes = {
|
await snapshot_platform(hass, entity_registry, snapshot, config_entry.entry_id)
|
||||||
"current_temperature": None,
|
|
||||||
"friendly_name": "Water Heater",
|
|
||||||
"max_temp": 31.0,
|
|
||||||
"min_temp": 16.0,
|
|
||||||
"operation_list": ["auto", "heat", "off"],
|
|
||||||
"operation_mode": "auto",
|
|
||||||
"supported_features": 3,
|
|
||||||
"target_temp_high": None,
|
|
||||||
"target_temp_low": None,
|
|
||||||
"temperature": 65.0,
|
|
||||||
}
|
|
||||||
# Only test for a subset of attributes in case
|
|
||||||
# HA changes the implementation and a new one appears
|
|
||||||
assert all(item in state.attributes.items() for item in expected_attributes.items())
|
|
||||||
|
|
||||||
state = hass.states.get("water_heater.second_water_heater")
|
|
||||||
assert state.state == "heat"
|
|
||||||
|
|
||||||
expected_attributes = {
|
|
||||||
"current_temperature": None,
|
|
||||||
"friendly_name": "Second Water Heater",
|
|
||||||
"max_temp": 31.0,
|
|
||||||
"min_temp": 16.0,
|
|
||||||
"operation_list": ["auto", "heat", "off"],
|
|
||||||
"operation_mode": "heat",
|
|
||||||
"supported_features": 3,
|
|
||||||
"target_temp_high": None,
|
|
||||||
"target_temp_low": None,
|
|
||||||
"temperature": 30.0,
|
|
||||||
}
|
|
||||||
# Only test for a subset of attributes in case
|
|
||||||
# HA changes the implementation and a new one appears
|
|
||||||
assert all(item in state.attributes.items() for item in expected_attributes.items())
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user