From b69a9a531032038a679c21ca643f695a03e10dd0 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 9 Sep 2026 15:36:29 +0200 Subject: [PATCH] Use snapshot_platform in airzone_cloud (#181728) --- .../airzone_cloud/snapshots/test_climate.ambr | 491 ++++++++++++++++++ .../airzone_cloud/snapshots/test_select.ambr | 186 +++++++ .../components/airzone_cloud/test_climate.py | 188 ++----- tests/components/airzone_cloud/test_select.py | 49 +- tests/components/airzone_cloud/util.py | 4 +- 5 files changed, 740 insertions(+), 178 deletions(-) create mode 100644 tests/components/airzone_cloud/snapshots/test_climate.ambr create mode 100644 tests/components/airzone_cloud/snapshots/test_select.ambr diff --git a/tests/components/airzone_cloud/snapshots/test_climate.ambr b/tests/components/airzone_cloud/snapshots/test_climate.ambr new file mode 100644 index 000000000000..93d57121b21b --- /dev/null +++ b/tests/components/airzone_cloud/snapshots/test_climate.ambr @@ -0,0 +1,491 @@ +# serializer version: 1 +# name: test_airzone_create_climates[climate.bron-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + : list([ + 'low', + 'medium', + 'high', + ]), + : list([ + , + , + , + , + , + , + ]), + : 30.0, + : 15.0, + : 0.5, + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'climate', + 'entity_category': None, + 'entity_id': 'climate.bron', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': None, + 'platform': 'airzone_cloud', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': , + 'translation_key': None, + 'unique_id': 'aidoo1', + 'unit_of_measurement': None, + }) +# --- +# name: test_airzone_create_climates[climate.bron-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 21.0, + : 'high', + : list([ + 'low', + 'medium', + 'high', + ]), + : 'Bron', + : , + : list([ + , + , + , + , + , + , + ]), + : 30.0, + : 15.0, + : , + : 0.5, + : 22.0, + }), + 'context': , + 'entity_id': 'climate.bron', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_airzone_create_climates[climate.bron_pro-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + : list([ + 'auto', + '20%', + '40%', + '60%', + '80%', + '100%', + ]), + : list([ + , + , + , + , + , + , + ]), + : 30.0, + : 15.0, + : 0.5, + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'climate', + 'entity_category': None, + 'entity_id': 'climate.bron_pro', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': None, + 'platform': 'airzone_cloud', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': , + 'translation_key': None, + 'unique_id': 'aidoo_pro', + 'unit_of_measurement': None, + }) +# --- +# name: test_airzone_create_climates[climate.bron_pro-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 20.0, + : '60%', + : list([ + 'auto', + '20%', + '40%', + '60%', + '80%', + '100%', + ]), + : 'Bron Pro', + : , + : list([ + , + , + , + , + , + , + ]), + : 30.0, + : 15.0, + : , + : None, + : None, + : 0.5, + : 22.0, + }), + 'context': , + 'entity_id': 'climate.bron_pro', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'cool', + }) +# --- +# name: test_airzone_create_climates[climate.dormitorio-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + : list([ + , + , + , + , + , + ]), + : 30.0, + : 15.0, + : 0.5, + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'climate', + 'entity_category': None, + 'entity_id': 'climate.dormitorio', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': None, + 'platform': 'airzone_cloud', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': , + 'translation_key': None, + 'unique_id': 'zone2', + 'unit_of_measurement': None, + }) +# --- +# name: test_airzone_create_climates[climate.dormitorio-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 24, + : 25.0, + : 'Dormitorio', + : , + : list([ + , + , + , + , + , + ]), + : 30.0, + : 15.0, + : , + : 0.5, + : 24.0, + }), + 'context': , + 'entity_id': 'climate.dormitorio', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_airzone_create_climates[climate.group-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + : list([ + , + , + , + , + , + ]), + : 30.0, + : 15.0, + : 0.5, + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'climate', + 'entity_category': None, + 'entity_id': 'climate.group', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': None, + 'platform': 'airzone_cloud', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': , + 'translation_key': None, + 'unique_id': 'grp1', + 'unit_of_measurement': None, + }) +# --- +# name: test_airzone_create_climates[climate.group-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 27, + : 22.5, + : 'Group', + : , + : list([ + , + , + , + , + , + ]), + : 30.0, + : 15.0, + : , + : 0.5, + : 24.0, + }), + 'context': , + 'entity_id': 'climate.group', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'cool', + }) +# --- +# name: test_airzone_create_climates[climate.house-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + : list([ + , + , + , + , + , + , + ]), + : 30.0, + : 15.0, + : 0.5, + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'climate', + 'entity_category': None, + 'entity_id': 'climate.house', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': None, + 'platform': 'airzone_cloud', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': , + 'translation_key': None, + 'unique_id': 'inst1', + 'unit_of_measurement': None, + }) +# --- +# name: test_airzone_create_climates[climate.house-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 27, + : 21.5, + : 'House', + : , + : list([ + , + , + , + , + , + , + ]), + : 30.0, + : 15.0, + : , + : 0.5, + : 23.0, + }), + 'context': , + 'entity_id': 'climate.house', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'cool', + }) +# --- +# name: test_airzone_create_climates[climate.salon-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + : list([ + , + , + , + , + , + ]), + : 30.0, + : 15.0, + : 0.5, + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'climate', + 'entity_category': None, + 'entity_id': 'climate.salon', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': None, + 'platform': 'airzone_cloud', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': , + 'translation_key': None, + 'unique_id': 'zone1', + 'unit_of_measurement': None, + }) +# --- +# name: test_airzone_create_climates[climate.salon-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 30, + : 20.0, + : 'Salon', + : , + : list([ + , + , + , + , + , + ]), + : 30.0, + : 15.0, + : , + : 0.5, + : 24.0, + }), + 'context': , + 'entity_id': 'climate.salon', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'cool', + }) +# --- diff --git a/tests/components/airzone_cloud/snapshots/test_select.ambr b/tests/components/airzone_cloud/snapshots/test_select.ambr new file mode 100644 index 000000000000..205b7709ea2b --- /dev/null +++ b/tests/components/airzone_cloud/snapshots/test_select.ambr @@ -0,0 +1,186 @@ +# serializer version: 1 +# name: test_airzone_create_selects[select.dormitorio_air_quality_mode-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + : list([ + 'off', + 'on', + 'auto', + ]), + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'select', + 'entity_category': , + 'entity_id': 'select.dormitorio_air_quality_mode', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Air Quality mode', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Air Quality mode', + 'platform': 'airzone_cloud', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'air_quality', + 'unique_id': 'zone2_aq-mode-conf', + 'unit_of_measurement': None, + }) +# --- +# name: test_airzone_create_selects[select.dormitorio_air_quality_mode-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 'Dormitorio Air Quality mode', + : list([ + 'off', + 'on', + 'auto', + ]), + }), + 'context': , + 'entity_id': 'select.dormitorio_air_quality_mode', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'auto', + }) +# --- +# name: test_airzone_create_selects[select.salon_air_quality_mode-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + : list([ + 'off', + 'on', + 'auto', + ]), + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'select', + 'entity_category': , + 'entity_id': 'select.salon_air_quality_mode', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Air Quality mode', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Air Quality mode', + 'platform': 'airzone_cloud', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'air_quality', + 'unique_id': 'zone1_aq-mode-conf', + 'unit_of_measurement': None, + }) +# --- +# name: test_airzone_create_selects[select.salon_air_quality_mode-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 'Salon Air Quality mode', + : list([ + 'off', + 'on', + 'auto', + ]), + }), + 'context': , + 'entity_id': 'select.salon_air_quality_mode', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'auto', + }) +# --- +# name: test_airzone_create_selects[select.salon_mode-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + : list([ + 'cool', + 'dry', + 'fan', + 'heat', + ]), + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'select', + 'entity_category': None, + 'entity_id': 'select.salon_mode', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Mode', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Mode', + 'platform': 'airzone_cloud', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'modes', + 'unique_id': 'zone1_mode', + 'unit_of_measurement': None, + }) +# --- +# name: test_airzone_create_selects[select.salon_mode-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 'Salon Mode', + : list([ + 'cool', + 'dry', + 'fan', + 'heat', + ]), + }), + 'context': , + 'entity_id': 'select.salon_mode', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'cool', + }) +# --- diff --git a/tests/components/airzone_cloud/test_climate.py b/tests/components/airzone_cloud/test_climate.py index 2b587680a577..3597d4675e44 100644 --- a/tests/components/airzone_cloud/test_climate.py +++ b/tests/components/airzone_cloud/test_climate.py @@ -1,33 +1,24 @@ """The climate tests for the Airzone Cloud platform.""" +from collections.abc import Generator from unittest.mock import patch -from aioairzone_cloud.const import API_DEFAULT_TEMP_STEP from aioairzone_cloud.exceptions import AirzoneCloudError import pytest +from syrupy.assertion import SnapshotAssertion from homeassistant.components.climate import ( - ATTR_CURRENT_HUMIDITY, - ATTR_CURRENT_TEMPERATURE, ATTR_FAN_MODE, - ATTR_FAN_MODES, - ATTR_HVAC_ACTION, ATTR_HVAC_MODE, - ATTR_HVAC_MODES, - ATTR_MAX_TEMP, - ATTR_MIN_TEMP, ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, - ATTR_TARGET_TEMP_STEP, DOMAIN as CLIMATE_DOMAIN, FAN_AUTO, - FAN_HIGH, FAN_LOW, - FAN_MEDIUM, SERVICE_SET_FAN_MODE, SERVICE_SET_HVAC_MODE, SERVICE_SET_TEMPERATURE, - HVACAction, + ClimateEntityStateAttribute, HVACMode, ) from homeassistant.const import ( @@ -35,149 +26,34 @@ from homeassistant.const import ( ATTR_TEMPERATURE, SERVICE_TURN_OFF, SERVICE_TURN_ON, + Platform, ) from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError +from homeassistant.helpers import entity_registry as er from .util import async_init_integration +from tests.common import snapshot_platform -async def test_airzone_create_climates(hass: HomeAssistant) -> None: + +@pytest.fixture(autouse=True) +def override_platforms() -> Generator[None]: + """Override PLATFORMS.""" + with patch("homeassistant.components.airzone_cloud.PLATFORMS", [Platform.CLIMATE]): + yield + + +async def test_airzone_create_climates( + hass: HomeAssistant, + entity_registry: er.EntityRegistry, + snapshot: SnapshotAssertion, +) -> None: """Test creation of climates.""" - await async_init_integration(hass) + config_entry = await async_init_integration(hass) - # Aidoos - state = hass.states.get("climate.bron") - assert state.state == HVACMode.OFF - assert ATTR_CURRENT_HUMIDITY not in state.attributes - assert state.attributes[ATTR_CURRENT_TEMPERATURE] == 21.0 - assert state.attributes[ATTR_FAN_MODE] == FAN_HIGH - assert state.attributes[ATTR_FAN_MODES] == [ - FAN_LOW, - FAN_MEDIUM, - FAN_HIGH, - ] - assert state.attributes[ATTR_HVAC_ACTION] == HVACAction.OFF - assert state.attributes[ATTR_HVAC_MODES] == [ - HVACMode.HEAT_COOL, - HVACMode.COOL, - HVACMode.HEAT, - HVACMode.FAN_ONLY, - HVACMode.DRY, - HVACMode.OFF, - ] - assert state.attributes[ATTR_MAX_TEMP] == 30 - assert state.attributes[ATTR_MIN_TEMP] == 15 - assert state.attributes[ATTR_TARGET_TEMP_STEP] == API_DEFAULT_TEMP_STEP - assert state.attributes[ATTR_TEMPERATURE] == 22.0 - - state = hass.states.get("climate.bron_pro") - assert state.state == HVACMode.COOL - assert ATTR_CURRENT_HUMIDITY not in state.attributes - assert state.attributes[ATTR_CURRENT_TEMPERATURE] == 20.0 - assert state.attributes[ATTR_FAN_MODE] == "60%" - assert state.attributes[ATTR_FAN_MODES] == [ - FAN_AUTO, - "20%", - "40%", - "60%", - "80%", - "100%", - ] - assert state.attributes[ATTR_HVAC_ACTION] == HVACAction.COOLING - assert state.attributes[ATTR_HVAC_MODES] == [ - HVACMode.HEAT_COOL, - HVACMode.COOL, - HVACMode.HEAT, - HVACMode.FAN_ONLY, - HVACMode.DRY, - HVACMode.OFF, - ] - assert state.attributes[ATTR_MAX_TEMP] == 30 - assert state.attributes[ATTR_MIN_TEMP] == 15 - assert state.attributes[ATTR_TARGET_TEMP_STEP] == API_DEFAULT_TEMP_STEP - assert state.attributes.get(ATTR_TEMPERATURE) == 22.0 - - # Groups - state = hass.states.get("climate.group") - assert state.state == HVACMode.COOL - assert state.attributes[ATTR_CURRENT_HUMIDITY] == 27 - assert state.attributes[ATTR_CURRENT_TEMPERATURE] == 22.5 - assert ATTR_FAN_MODE not in state.attributes - assert ATTR_FAN_MODES not in state.attributes - assert state.attributes[ATTR_HVAC_ACTION] == HVACAction.COOLING - assert state.attributes[ATTR_HVAC_MODES] == [ - HVACMode.COOL, - HVACMode.HEAT, - HVACMode.FAN_ONLY, - HVACMode.DRY, - HVACMode.OFF, - ] - assert state.attributes[ATTR_MAX_TEMP] == 30 - assert state.attributes[ATTR_MIN_TEMP] == 15 - assert state.attributes[ATTR_TARGET_TEMP_STEP] == API_DEFAULT_TEMP_STEP - assert state.attributes[ATTR_TEMPERATURE] == 24.0 - - # Installations - state = hass.states.get("climate.house") - assert state.state == HVACMode.COOL - assert state.attributes[ATTR_CURRENT_HUMIDITY] == 27 - assert state.attributes[ATTR_CURRENT_TEMPERATURE] == 21.5 - assert ATTR_FAN_MODE not in state.attributes - assert ATTR_FAN_MODES not in state.attributes - assert state.attributes[ATTR_HVAC_ACTION] == HVACAction.COOLING - assert state.attributes[ATTR_HVAC_MODES] == [ - HVACMode.HEAT_COOL, - HVACMode.COOL, - HVACMode.HEAT, - HVACMode.FAN_ONLY, - HVACMode.DRY, - HVACMode.OFF, - ] - assert state.attributes[ATTR_MAX_TEMP] == 30 - assert state.attributes[ATTR_MIN_TEMP] == 15 - assert state.attributes[ATTR_TARGET_TEMP_STEP] == API_DEFAULT_TEMP_STEP - assert state.attributes[ATTR_TEMPERATURE] == 23.0 - - # Zones - state = hass.states.get("climate.dormitorio") - assert state.state == HVACMode.OFF - assert state.attributes[ATTR_CURRENT_HUMIDITY] == 24 - assert state.attributes[ATTR_CURRENT_TEMPERATURE] == 25.0 - assert ATTR_FAN_MODE not in state.attributes - assert ATTR_FAN_MODES not in state.attributes - assert state.attributes[ATTR_HVAC_ACTION] == HVACAction.OFF - assert state.attributes[ATTR_HVAC_MODES] == [ - HVACMode.COOL, - HVACMode.HEAT, - HVACMode.FAN_ONLY, - HVACMode.DRY, - HVACMode.OFF, - ] - assert state.attributes[ATTR_MAX_TEMP] == 30 - assert state.attributes[ATTR_MIN_TEMP] == 15 - assert state.attributes[ATTR_TARGET_TEMP_STEP] == API_DEFAULT_TEMP_STEP - assert state.attributes[ATTR_TEMPERATURE] == 24.0 - - state = hass.states.get("climate.salon") - assert state.state == HVACMode.COOL - assert state.attributes[ATTR_CURRENT_HUMIDITY] == 30 - assert state.attributes[ATTR_CURRENT_TEMPERATURE] == 20.0 - assert ATTR_FAN_MODE not in state.attributes - assert ATTR_FAN_MODES not in state.attributes - assert state.attributes[ATTR_HVAC_ACTION] == HVACAction.COOLING - assert state.attributes[ATTR_HVAC_MODES] == [ - HVACMode.COOL, - HVACMode.HEAT, - HVACMode.FAN_ONLY, - HVACMode.DRY, - HVACMode.OFF, - ] - assert state.attributes[ATTR_MAX_TEMP] == 30 - assert state.attributes[ATTR_MIN_TEMP] == 15 - assert state.attributes[ATTR_TARGET_TEMP_STEP] == API_DEFAULT_TEMP_STEP - assert state.attributes[ATTR_TEMPERATURE] == 24.0 + await snapshot_platform(hass, entity_registry, snapshot, config_entry.entry_id) async def test_airzone_climate_turn_on_off(hass: HomeAssistant) -> None: @@ -323,7 +199,7 @@ async def test_airzone_climate_set_fan_mode(hass: HomeAssistant) -> None: ) state = hass.states.get("climate.bron") - assert state.attributes[ATTR_FAN_MODE] == FAN_LOW + assert state.attributes[ClimateEntityStateAttribute.FAN_MODE] == FAN_LOW with patch( "homeassistant.components.airzone_cloud.AirzoneCloudApi.api_patch_device", @@ -340,7 +216,7 @@ async def test_airzone_climate_set_fan_mode(hass: HomeAssistant) -> None: ) state = hass.states.get("climate.bron_pro") - assert state.attributes[ATTR_FAN_MODE] == FAN_AUTO + assert state.attributes[ClimateEntityStateAttribute.FAN_MODE] == FAN_AUTO async def test_airzone_climate_set_hvac_mode(hass: HomeAssistant) -> None: @@ -536,7 +412,7 @@ async def test_airzone_climate_set_temp(hass: HomeAssistant) -> None: ) state = hass.states.get("climate.group") - assert state.attributes[ATTR_TEMPERATURE] == 20.5 + assert state.attributes[ClimateEntityStateAttribute.TARGET_TEMPERATURE] == 20.5 # Installations with patch( @@ -556,7 +432,7 @@ async def test_airzone_climate_set_temp(hass: HomeAssistant) -> None: state = hass.states.get("climate.house") assert state.state == HVACMode.HEAT - assert state.attributes[ATTR_TEMPERATURE] == 20.5 + assert state.attributes[ClimateEntityStateAttribute.TARGET_TEMPERATURE] == 20.5 # Zones with patch( @@ -576,7 +452,7 @@ async def test_airzone_climate_set_temp(hass: HomeAssistant) -> None: state = hass.states.get("climate.salon") assert state.state == HVACMode.HEAT - assert state.attributes[ATTR_TEMPERATURE] == 20.5 + assert state.attributes[ClimateEntityStateAttribute.TARGET_TEMPERATURE] == 20.5 # Aidoo Pro with Double Setpoint with patch( @@ -597,8 +473,8 @@ async def test_airzone_climate_set_temp(hass: HomeAssistant) -> None: state = hass.states.get("climate.bron_pro") assert state.state == HVACMode.HEAT_COOL - assert state.attributes.get(ATTR_TARGET_TEMP_HIGH) == 25.0 - assert state.attributes.get(ATTR_TARGET_TEMP_LOW) == 20.0 + assert state.attributes.get(ClimateEntityStateAttribute.TARGET_TEMP_HIGH) == 25.0 + assert state.attributes.get(ClimateEntityStateAttribute.TARGET_TEMP_LOW) == 20.0 async def test_airzone_climate_set_temp_error(hass: HomeAssistant) -> None: @@ -625,7 +501,7 @@ async def test_airzone_climate_set_temp_error(hass: HomeAssistant) -> None: ) state = hass.states.get("climate.bron") - assert state.attributes[ATTR_TEMPERATURE] == 22.0 + assert state.attributes[ClimateEntityStateAttribute.TARGET_TEMPERATURE] == 22.0 # Groups with ( @@ -646,7 +522,7 @@ async def test_airzone_climate_set_temp_error(hass: HomeAssistant) -> None: ) state = hass.states.get("climate.group") - assert state.attributes[ATTR_TEMPERATURE] == 24.0 + assert state.attributes[ClimateEntityStateAttribute.TARGET_TEMPERATURE] == 24.0 # Installations with ( @@ -667,7 +543,7 @@ async def test_airzone_climate_set_temp_error(hass: HomeAssistant) -> None: ) state = hass.states.get("climate.house") - assert state.attributes[ATTR_TEMPERATURE] == 23.0 + assert state.attributes[ClimateEntityStateAttribute.TARGET_TEMPERATURE] == 23.0 # Zones with ( @@ -688,4 +564,4 @@ async def test_airzone_climate_set_temp_error(hass: HomeAssistant) -> None: ) state = hass.states.get("climate.salon") - assert state.attributes[ATTR_TEMPERATURE] == 24.0 + assert state.attributes[ClimateEntityStateAttribute.TARGET_TEMPERATURE] == 24.0 diff --git a/tests/components/airzone_cloud/test_select.py b/tests/components/airzone_cloud/test_select.py index d0993365083a..95e8af0dee1c 100644 --- a/tests/components/airzone_cloud/test_select.py +++ b/tests/components/airzone_cloud/test_select.py @@ -1,41 +1,48 @@ """The select tests for the Airzone Cloud platform.""" +from collections.abc import Generator from unittest.mock import patch import pytest +from syrupy.assertion import SnapshotAssertion -from homeassistant.components.select import ATTR_OPTIONS, DOMAIN as SELECT_DOMAIN -from homeassistant.const import ATTR_ENTITY_ID, ATTR_OPTION, SERVICE_SELECT_OPTION +from homeassistant.components.select import DOMAIN as SELECT_DOMAIN +from homeassistant.const import ( + ATTR_ENTITY_ID, + ATTR_OPTION, + SERVICE_SELECT_OPTION, + Platform, +) from homeassistant.core import HomeAssistant from homeassistant.exceptions import ServiceValidationError +from homeassistant.helpers import entity_registry as er from .util import async_init_integration +from tests.common import snapshot_platform + + +@pytest.fixture(autouse=True) +def override_platforms() -> Generator[None]: + """Override PLATFORMS.""" + with patch("homeassistant.components.airzone_cloud.PLATFORMS", [Platform.SELECT]): + yield + @pytest.mark.usefixtures("entity_registry_enabled_by_default") -async def test_airzone_create_selects(hass: HomeAssistant) -> None: +async def test_airzone_create_selects( + hass: HomeAssistant, + entity_registry: er.EntityRegistry, + snapshot: SnapshotAssertion, +) -> None: """Test creation of selects.""" - await async_init_integration(hass) + config_entry = await async_init_integration(hass) - # Zones - state = hass.states.get("select.dormitorio_air_quality_mode") - assert state.state == "auto" + await snapshot_platform(hass, entity_registry, snapshot, config_entry.entry_id) - state = hass.states.get("select.dormitorio_mode") - assert state is None - - state = hass.states.get("select.salon_air_quality_mode") - assert state.state == "auto" - - state = hass.states.get("select.salon_mode") - assert state.state == "cool" - assert state.attributes.get(ATTR_OPTIONS) == [ - "cool", - "dry", - "fan", - "heat", - ] + # Mode selects are only created for master zones + assert hass.states.get("select.dormitorio_mode") is None async def test_airzone_select_air_quality_mode(hass: HomeAssistant) -> None: diff --git a/tests/components/airzone_cloud/util.py b/tests/components/airzone_cloud/util.py index 835011f8c8c8..4c14bd906d1e 100644 --- a/tests/components/airzone_cloud/util.py +++ b/tests/components/airzone_cloud/util.py @@ -529,7 +529,7 @@ def mock_get_webserver(webserver: WebServer, devices: bool) -> dict[str, Any]: async def async_init_integration( hass: HomeAssistant, -) -> None: +) -> MockConfigEntry: """Set up the Airzone integration in Home Assistant.""" config_entry = MockConfigEntry( @@ -568,3 +568,5 @@ async def async_init_integration( ): await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() + + return config_entry