mirror of
https://github.com/home-assistant/core.git
synced 2025-08-02 10:08:23 +00:00
Improve Tado sensor tests (#149809)
This commit is contained in:
parent
b5e4ae4a53
commit
5ce2729dc2
1240
tests/components/tado/snapshots/test_sensor.ambr
Normal file
1240
tests/components/tado/snapshots/test_sensor.ambr
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,62 +1,35 @@
|
||||
"""The sensor tests for the tado platform."""
|
||||
|
||||
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.helpers import entity_registry as er
|
||||
|
||||
from .util import async_init_integration
|
||||
|
||||
from tests.common import MockConfigEntry, snapshot_platform
|
||||
|
||||
async def test_air_con_create_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.SENSOR]):
|
||||
yield
|
||||
|
||||
|
||||
async def test_entities(
|
||||
hass: HomeAssistant, entity_registry: er.EntityRegistry, snapshot: SnapshotAssertion
|
||||
) -> None:
|
||||
"""Test creation of sensor entities."""
|
||||
|
||||
await async_init_integration(hass)
|
||||
|
||||
state = hass.states.get("sensor.air_conditioning_tado_mode")
|
||||
assert state.state == "HOME"
|
||||
config_entry: MockConfigEntry = hass.config_entries.async_entries(DOMAIN)[0]
|
||||
|
||||
state = hass.states.get("sensor.air_conditioning_temperature")
|
||||
assert state.state == "24.76"
|
||||
|
||||
state = hass.states.get("sensor.air_conditioning_ac")
|
||||
assert state.state == "ON"
|
||||
|
||||
state = hass.states.get("sensor.air_conditioning_humidity")
|
||||
assert state.state == "60.9"
|
||||
|
||||
|
||||
async def test_home_create_sensors(hass: HomeAssistant) -> None:
|
||||
"""Test creation of home sensors."""
|
||||
|
||||
await async_init_integration(hass)
|
||||
|
||||
state = hass.states.get("sensor.home_name_outdoor_temperature")
|
||||
assert state.state == "7.46"
|
||||
|
||||
state = hass.states.get("sensor.home_name_solar_percentage")
|
||||
assert state.state == "2.1"
|
||||
|
||||
state = hass.states.get("sensor.home_name_weather_condition")
|
||||
assert state.state == "fog"
|
||||
|
||||
|
||||
async def test_heater_create_sensors(hass: HomeAssistant) -> None:
|
||||
"""Test creation of heater sensors."""
|
||||
|
||||
await async_init_integration(hass)
|
||||
|
||||
state = hass.states.get("sensor.baseboard_heater_tado_mode")
|
||||
assert state.state == "HOME"
|
||||
|
||||
state = hass.states.get("sensor.baseboard_heater_temperature")
|
||||
assert state.state == "20.65"
|
||||
|
||||
state = hass.states.get("sensor.baseboard_heater_humidity")
|
||||
assert state.state == "45.2"
|
||||
|
||||
|
||||
async def test_water_heater_create_sensors(hass: HomeAssistant) -> None:
|
||||
"""Test creation of water heater sensors."""
|
||||
|
||||
await async_init_integration(hass)
|
||||
|
||||
state = hass.states.get("sensor.water_heater_tado_mode")
|
||||
assert state.state == "HOME"
|
||||
await snapshot_platform(hass, entity_registry, snapshot, config_entry.entry_id)
|
||||
|
Loading…
x
Reference in New Issue
Block a user