From 5a0fe8e2d3d1713a226bb47525ecedb90f808c2b Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 10 Sep 2026 10:27:39 +0200 Subject: [PATCH] Use snapshot_platform helper in atag climate tests (#181823) --- .../atag/snapshots/test_climate.ambr | 83 +++++++++++++++++++ tests/components/atag/test_climate.py | 33 +++++--- 2 files changed, 106 insertions(+), 10 deletions(-) create mode 100644 tests/components/atag/snapshots/test_climate.ambr diff --git a/tests/components/atag/snapshots/test_climate.ambr b/tests/components/atag/snapshots/test_climate.ambr new file mode 100644 index 000000000000..5e96e0dc77e2 --- /dev/null +++ b/tests/components/atag/snapshots/test_climate.ambr @@ -0,0 +1,83 @@ +# serializer version: 1 +# name: test_all_entities[climate.atag_thermostat_atag-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + : list([ + , + , + ]), + : 35, + : 7, + : list([ + 'Manual', + 'Auto', + 'Extend', + 'away', + 'boost', + ]), + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'climate', + 'entity_category': None, + 'entity_id': 'climate.atag_thermostat_atag', + 'has_entity_name': False, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Atag', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Atag', + 'platform': 'atag', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': , + 'translation_key': None, + 'unique_id': 'xxxx-xxxx-xxxx_xx-xx-xxx-xxx-climate', + 'unit_of_measurement': None, + }) +# --- +# name: test_all_entities[climate.atag_thermostat_atag-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 20, + : 'Atag Thermostat Atag', + : , + : list([ + , + , + ]), + : 35, + : 7, + : 'Manual', + : list([ + 'Manual', + 'Auto', + 'Extend', + 'away', + 'boost', + ]), + : , + : 12, + }), + 'context': , + 'entity_id': 'climate.atag_thermostat_atag', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'heat', + }) +# --- diff --git a/tests/components/atag/test_climate.py b/tests/components/atag/test_climate.py index 71b929157605..46f46ba0d854 100644 --- a/tests/components/atag/test_climate.py +++ b/tests/components/atag/test_climate.py @@ -1,10 +1,13 @@ """Tests for the Atag climate platform.""" +from collections.abc import Generator from unittest.mock import PropertyMock, patch +import pytest +from syrupy.assertion import SnapshotAssertion + from homeassistant.components.atag.climate import PRESET_MAP from homeassistant.components.climate import ( - ATTR_HVAC_ACTION, ATTR_HVAC_MODE, ATTR_PRESET_MODE, DOMAIN as CLIMATE_DOMAIN, @@ -12,34 +15,44 @@ from homeassistant.components.climate import ( SERVICE_SET_HVAC_MODE, SERVICE_SET_PRESET_MODE, SERVICE_SET_TEMPERATURE, - HVACAction, HVACMode, ) from homeassistant.components.homeassistant import DOMAIN as HA_DOMAIN -from homeassistant.const import ATTR_ENTITY_ID, ATTR_TEMPERATURE, STATE_UNKNOWN +from homeassistant.const import ( + ATTR_ENTITY_ID, + ATTR_TEMPERATURE, + STATE_UNKNOWN, + Platform, +) from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_registry as er from homeassistant.setup import async_setup_component from . import UID, init_integration +from tests.common import snapshot_platform from tests.test_util.aiohttp import AiohttpClientMocker CLIMATE_ID = "climate.atag_thermostat_atag" -async def test_climate( +@pytest.fixture(autouse=True) +def override_platforms() -> Generator[None]: + """Override PLATFORMS.""" + with patch("homeassistant.components.atag.PLATFORMS", [Platform.CLIMATE]): + yield + + +async def test_all_entities( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, entity_registry: er.EntityRegistry, + snapshot: SnapshotAssertion, ) -> None: - """Test the creation and values of Atag climate device.""" - await init_integration(hass, aioclient_mock) + """Test all entities.""" + entry = await init_integration(hass, aioclient_mock) - assert entity_registry.async_is_registered(CLIMATE_ID) - entity = entity_registry.async_get(CLIMATE_ID) - assert entity.unique_id == f"{UID}-climate" - assert hass.states.get(CLIMATE_ID).attributes[ATTR_HVAC_ACTION] == HVACAction.IDLE + await snapshot_platform(hass, entity_registry, snapshot, entry.entry_id) async def test_setting_climate(