mirror of
https://github.com/home-assistant/core.git
synced 2025-08-02 18:18:21 +00:00
Improve Tado binary sensor tests (#149807)
This commit is contained in:
parent
506431c75f
commit
a08c3c9f44
1230
tests/components/tado/snapshots/test_binary_sensor.ambr
Normal file
1230
tests/components/tado/snapshots/test_binary_sensor.ambr
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,69 +1,35 @@
|
|||||||
"""The sensor tests for the tado platform."""
|
"""The binary sensor tests for the tado platform."""
|
||||||
|
|
||||||
from homeassistant.const import STATE_OFF, STATE_ON
|
from collections.abc import AsyncGenerator
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from syrupy.assertion import SnapshotAssertion
|
||||||
|
|
||||||
|
from homeassistant.components.tado import DOMAIN
|
||||||
|
from homeassistant.const import 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
|
||||||
|
|
||||||
async def test_air_con_create_binary_sensors(hass: HomeAssistant) -> None:
|
|
||||||
"""Test creation of aircon sensors."""
|
@pytest.fixture(autouse=True)
|
||||||
|
def setup_platforms() -> AsyncGenerator[None]:
|
||||||
|
"""Set up the platforms for the tests."""
|
||||||
|
with patch("homeassistant.components.tado.PLATFORMS", [Platform.BINARY_SENSOR]):
|
||||||
|
yield
|
||||||
|
|
||||||
|
|
||||||
|
async def test_entities(
|
||||||
|
hass: HomeAssistant, entity_registry: er.EntityRegistry, snapshot: SnapshotAssertion
|
||||||
|
) -> None:
|
||||||
|
"""Test creation of binary sensor."""
|
||||||
|
|
||||||
await async_init_integration(hass)
|
await async_init_integration(hass)
|
||||||
|
|
||||||
state = hass.states.get("binary_sensor.air_conditioning_power")
|
config_entry: MockConfigEntry = hass.config_entries.async_entries(DOMAIN)[0]
|
||||||
assert state.state == STATE_ON
|
|
||||||
|
|
||||||
state = hass.states.get("binary_sensor.air_conditioning_connectivity")
|
await snapshot_platform(hass, entity_registry, snapshot, config_entry.entry_id)
|
||||||
assert state.state == STATE_ON
|
|
||||||
|
|
||||||
state = hass.states.get("binary_sensor.air_conditioning_overlay")
|
|
||||||
assert state.state == STATE_ON
|
|
||||||
|
|
||||||
state = hass.states.get("binary_sensor.air_conditioning_window")
|
|
||||||
assert state.state == STATE_OFF
|
|
||||||
|
|
||||||
|
|
||||||
async def test_heater_create_binary_sensors(hass: HomeAssistant) -> None:
|
|
||||||
"""Test creation of heater sensors."""
|
|
||||||
|
|
||||||
await async_init_integration(hass)
|
|
||||||
|
|
||||||
state = hass.states.get("binary_sensor.baseboard_heater_power")
|
|
||||||
assert state.state == STATE_ON
|
|
||||||
|
|
||||||
state = hass.states.get("binary_sensor.baseboard_heater_connectivity")
|
|
||||||
assert state.state == STATE_ON
|
|
||||||
|
|
||||||
state = hass.states.get("binary_sensor.baseboard_heater_early_start")
|
|
||||||
assert state.state == STATE_OFF
|
|
||||||
|
|
||||||
state = hass.states.get("binary_sensor.baseboard_heater_overlay")
|
|
||||||
assert state.state == STATE_ON
|
|
||||||
|
|
||||||
state = hass.states.get("binary_sensor.baseboard_heater_window")
|
|
||||||
assert state.state == STATE_OFF
|
|
||||||
|
|
||||||
|
|
||||||
async def test_water_heater_create_binary_sensors(hass: HomeAssistant) -> None:
|
|
||||||
"""Test creation of water heater sensors."""
|
|
||||||
|
|
||||||
await async_init_integration(hass)
|
|
||||||
|
|
||||||
state = hass.states.get("binary_sensor.water_heater_connectivity")
|
|
||||||
assert state.state == STATE_ON
|
|
||||||
|
|
||||||
state = hass.states.get("binary_sensor.water_heater_overlay")
|
|
||||||
assert state.state == STATE_OFF
|
|
||||||
|
|
||||||
state = hass.states.get("binary_sensor.water_heater_power")
|
|
||||||
assert state.state == STATE_ON
|
|
||||||
|
|
||||||
|
|
||||||
async def test_home_create_binary_sensors(hass: HomeAssistant) -> None:
|
|
||||||
"""Test creation of home binary sensors."""
|
|
||||||
|
|
||||||
await async_init_integration(hass)
|
|
||||||
|
|
||||||
state = hass.states.get("binary_sensor.wr1_connection_state")
|
|
||||||
assert state.state == STATE_ON
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user