diff --git a/tests/components/avea/snapshots/test_light.ambr b/tests/components/avea/snapshots/test_light.ambr new file mode 100644 index 000000000000..f4d16c7d98b1 --- /dev/null +++ b/tests/components/avea/snapshots/test_light.ambr @@ -0,0 +1,64 @@ +# serializer version: 1 +# name: test_all_entities[light.bedroom-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + : list([ + , + ]), + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'light', + 'entity_category': None, + 'entity_id': 'light.bedroom', + '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': 'avea', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': 'AA:BB:CC:DD:EE:FF', + 'unit_of_measurement': None, + }) +# --- +# name: test_all_entities[light.bedroom-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : None, + : None, + : 'Bedroom', + : None, + : None, + : list([ + , + ]), + : , + : None, + }), + 'context': , + 'entity_id': 'light.bedroom', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- diff --git a/tests/components/avea/test_light.py b/tests/components/avea/test_light.py index 6f87a3b432fa..4275ba55f49d 100644 --- a/tests/components/avea/test_light.py +++ b/tests/components/avea/test_light.py @@ -6,21 +6,21 @@ from unittest.mock import MagicMock, call, patch from freezegun.api import FrozenDateTimeFactory import pytest +from syrupy.assertion import SnapshotAssertion from homeassistant.components.avea.const import UNKNOWN_NAME from homeassistant.components.light import ( ATTR_BRIGHTNESS, ATTR_HS_COLOR, - ATTR_SUPPORTED_COLOR_MODES, - ColorMode, + LightEntityStateAttribute, ) from homeassistant.const import ATTR_ENTITY_ID, STATE_OFF, STATE_ON from homeassistant.core import HomeAssistant -from homeassistant.helpers import device_registry as dr +from homeassistant.helpers import device_registry as dr, entity_registry as er from . import AVEA_DISCOVERY_INFO, AVEA_FIRMWARE_VERSION, AVEA_SERIAL_NUMBER -from tests.common import MockConfigEntry, async_fire_time_changed +from tests.common import MockConfigEntry, async_fire_time_changed, snapshot_platform @pytest.fixture @@ -63,16 +63,16 @@ async def setup_integration( yield mock_bulb -async def test_init_state( +@pytest.mark.usefixtures("setup_integration") +async def test_all_entities( hass: HomeAssistant, - setup_integration: MagicMock, + entity_registry: er.EntityRegistry, + mock_config_entry: MockConfigEntry, + snapshot: SnapshotAssertion, ) -> None: - """Test the initial state.""" - state = hass.states.get("light.bedroom") - assert state is not None - assert state.state == STATE_OFF - assert state.name == "Bedroom" - assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.HS] + """Test all entities.""" + + await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id) async def test_device_info( @@ -257,7 +257,7 @@ async def test_turn_on_restores_last_brightness( state = hass.states.get("light.bedroom") assert state is not None - assert state.attributes[ATTR_BRIGHTNESS] == 200 + assert state.attributes[LightEntityStateAttribute.BRIGHTNESS] == 200 bulb.set_brightness.reset_mock() await hass.services.async_call( @@ -280,7 +280,7 @@ async def test_turn_on_restores_last_brightness( state = hass.states.get("light.bedroom") assert state is not None assert state.state == STATE_OFF - assert state.attributes[ATTR_BRIGHTNESS] is None + assert state.attributes[LightEntityStateAttribute.BRIGHTNESS] is None bulb.set_brightness.reset_mock() await hass.services.async_call( @@ -299,7 +299,7 @@ async def test_update_state( state = hass.states.get("light.bedroom") assert state is not None assert state.state == STATE_OFF - assert state.attributes[ATTR_BRIGHTNESS] is None + assert state.attributes[LightEntityStateAttribute.BRIGHTNESS] is None bulb = setup_integration bulb.reset_mock() @@ -328,8 +328,8 @@ async def test_update_state( state = hass.states.get("light.bedroom") assert state is not None assert state.state == STATE_ON - assert state.attributes[ATTR_BRIGHTNESS] == 128 - assert state.attributes[ATTR_HS_COLOR] == (120.0, 100.0) + assert state.attributes[LightEntityStateAttribute.BRIGHTNESS] == 128 + assert state.attributes[LightEntityStateAttribute.HS_COLOR] == (120.0, 100.0) async def test_update_state_uses_cached_values_when_connect_fails( @@ -354,5 +354,5 @@ async def test_update_state_uses_cached_values_when_connect_fails( state = hass.states.get("light.bedroom") assert state is not None assert state.state == STATE_ON - assert state.attributes[ATTR_BRIGHTNESS] == 128 - assert state.attributes[ATTR_HS_COLOR] == (120.0, 100.0) + assert state.attributes[LightEntityStateAttribute.BRIGHTNESS] == 128 + assert state.attributes[LightEntityStateAttribute.HS_COLOR] == (120.0, 100.0)