mirror of
https://github.com/home-assistant/core.git
synced 2026-09-25 17:04:04 -04:00
Use snapshot_platform helper in avea light tests (#181822)
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
# serializer version: 1
|
||||
# name: test_all_entities[light.bedroom-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': list([
|
||||
None,
|
||||
]),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
<LightEntityCapabilityAttribute.SUPPORTED_COLOR_MODES: 'supported_color_modes'>: list([
|
||||
<ColorMode.HS: 'hs'>,
|
||||
]),
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'light',
|
||||
'entity_category': None,
|
||||
'entity_id': 'light.bedroom',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'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({
|
||||
<LightEntityStateAttribute.BRIGHTNESS: 'brightness'>: None,
|
||||
<LightEntityStateAttribute.COLOR_MODE: 'color_mode'>: None,
|
||||
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Bedroom',
|
||||
<LightEntityStateAttribute.HS_COLOR: 'hs_color'>: None,
|
||||
<LightEntityStateAttribute.RGB_COLOR: 'rgb_color'>: None,
|
||||
<LightEntityCapabilityAttribute.SUPPORTED_COLOR_MODES: 'supported_color_modes'>: list([
|
||||
<ColorMode.HS: 'hs'>,
|
||||
]),
|
||||
<EntityStateAttribute.SUPPORTED_FEATURES: 'supported_features'>: <LightEntityFeature: 0>,
|
||||
<LightEntityStateAttribute.XY_COLOR: 'xy_color'>: None,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'light.bedroom',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user