mirror of
https://github.com/home-assistant/core.git
synced 2025-08-02 10:08:23 +00:00
Improve Tado switch tests (#149810)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
3d4386ea6d
commit
b5e4ae4a53
49
tests/components/tado/snapshots/test_switch.ambr
Normal file
49
tests/components/tado/snapshots/test_switch.ambr
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# serializer version: 1
|
||||||
|
# name: test_entities[switch.baseboard_heater_child_lock-entry]
|
||||||
|
EntityRegistryEntrySnapshot({
|
||||||
|
'aliases': set({
|
||||||
|
}),
|
||||||
|
'area_id': None,
|
||||||
|
'capabilities': None,
|
||||||
|
'config_entry_id': <ANY>,
|
||||||
|
'config_subentry_id': <ANY>,
|
||||||
|
'device_class': None,
|
||||||
|
'device_id': <ANY>,
|
||||||
|
'disabled_by': None,
|
||||||
|
'domain': 'switch',
|
||||||
|
'entity_category': None,
|
||||||
|
'entity_id': 'switch.baseboard_heater_child_lock',
|
||||||
|
'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': 'Child lock',
|
||||||
|
'platform': 'tado',
|
||||||
|
'previous_unique_id': None,
|
||||||
|
'suggested_object_id': None,
|
||||||
|
'supported_features': 0,
|
||||||
|
'translation_key': 'child_lock',
|
||||||
|
'unique_id': '1 1 child-lock',
|
||||||
|
'unit_of_measurement': None,
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_entities[switch.baseboard_heater_child_lock-state]
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'friendly_name': 'Baseboard Heater Child lock',
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'switch.baseboard_heater_child_lock',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_reported': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': 'off',
|
||||||
|
})
|
||||||
|
# ---
|
@ -1,28 +1,45 @@
|
|||||||
"""The sensor tests for the tado platform."""
|
"""The switch tests for the tado platform."""
|
||||||
|
|
||||||
|
from collections.abc import AsyncGenerator
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from syrupy.assertion import SnapshotAssertion
|
||||||
|
|
||||||
from homeassistant.components.switch import (
|
from homeassistant.components.switch import (
|
||||||
DOMAIN as SWITCH_DOMAIN,
|
DOMAIN as SWITCH_DOMAIN,
|
||||||
SERVICE_TURN_OFF,
|
SERVICE_TURN_OFF,
|
||||||
SERVICE_TURN_ON,
|
SERVICE_TURN_ON,
|
||||||
)
|
)
|
||||||
from homeassistant.const import ATTR_ENTITY_ID, STATE_OFF
|
from homeassistant.components.tado import DOMAIN
|
||||||
|
from homeassistant.const import ATTR_ENTITY_ID, 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
|
||||||
|
|
||||||
CHILD_LOCK_SWITCH_ENTITY = "switch.baseboard_heater_child_lock"
|
CHILD_LOCK_SWITCH_ENTITY = "switch.baseboard_heater_child_lock"
|
||||||
|
|
||||||
|
|
||||||
async def test_child_lock(hass: HomeAssistant) -> None:
|
@pytest.fixture(autouse=True)
|
||||||
"""Test creation of child lock entity."""
|
def setup_platforms() -> AsyncGenerator[None]:
|
||||||
|
"""Set up the platforms for the tests."""
|
||||||
|
with patch("homeassistant.components.tado.PLATFORMS", [Platform.SWITCH]):
|
||||||
|
yield
|
||||||
|
|
||||||
|
|
||||||
|
async def test_entities(
|
||||||
|
hass: HomeAssistant, entity_registry: er.EntityRegistry, snapshot: SnapshotAssertion
|
||||||
|
) -> None:
|
||||||
|
"""Test creation of switch entities."""
|
||||||
|
|
||||||
await async_init_integration(hass)
|
await async_init_integration(hass)
|
||||||
state = hass.states.get(CHILD_LOCK_SWITCH_ENTITY)
|
|
||||||
assert state.state == STATE_OFF
|
config_entry: MockConfigEntry = hass.config_entries.async_entries(DOMAIN)[0]
|
||||||
|
|
||||||
|
await snapshot_platform(hass, entity_registry, snapshot, config_entry.entry_id)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user