mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Improve test coverage for ESPHome deep sleep entities (#104476)
This commit is contained in:
parent
487ff8cd7f
commit
1c4d7e9588
@ -13,7 +13,13 @@ from aioesphomeapi import (
|
|||||||
UserService,
|
UserService,
|
||||||
)
|
)
|
||||||
|
|
||||||
from homeassistant.const import ATTR_RESTORED, STATE_OFF, STATE_ON, STATE_UNAVAILABLE
|
from homeassistant.const import (
|
||||||
|
ATTR_RESTORED,
|
||||||
|
EVENT_HOMEASSISTANT_STOP,
|
||||||
|
STATE_OFF,
|
||||||
|
STATE_ON,
|
||||||
|
STATE_UNAVAILABLE,
|
||||||
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from .conftest import MockESPHomeDevice
|
from .conftest import MockESPHomeDevice
|
||||||
@ -231,6 +237,19 @@ async def test_deep_sleep_device(
|
|||||||
assert state is not None
|
assert state is not None
|
||||||
assert state.state == STATE_UNAVAILABLE
|
assert state.state == STATE_UNAVAILABLE
|
||||||
|
|
||||||
|
await mock_device.mock_connect()
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
state = hass.states.get("binary_sensor.test_mybinary_sensor")
|
||||||
|
assert state is not None
|
||||||
|
assert state.state == STATE_ON
|
||||||
|
hass.bus.async_fire(EVENT_HOMEASSISTANT_STOP)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
# Verify we do not dispatch any more state updates or
|
||||||
|
# availability updates after the stop event is fired
|
||||||
|
state = hass.states.get("binary_sensor.test_mybinary_sensor")
|
||||||
|
assert state is not None
|
||||||
|
assert state.state == STATE_ON
|
||||||
|
|
||||||
|
|
||||||
async def test_esphome_device_without_friendly_name(
|
async def test_esphome_device_without_friendly_name(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user