mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Fix flakey advantage_air test (#117224)
This commit is contained in:
parent
f35b9c2b22
commit
9e107a02db
@ -3,6 +3,7 @@
|
||||
from datetime import timedelta
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from homeassistant.components.advantage_air import ADVANTAGE_AIR_SYNC_INTERVAL
|
||||
from homeassistant.config_entries import RELOAD_AFTER_UPDATE_DELAY
|
||||
from homeassistant.const import STATE_OFF, STATE_ON
|
||||
from homeassistant.core import HomeAssistant
|
||||
@ -74,11 +75,18 @@ async def test_binary_sensor_async_setup_entry(
|
||||
|
||||
async_fire_time_changed(
|
||||
hass,
|
||||
dt_util.utcnow() + timedelta(seconds=RELOAD_AFTER_UPDATE_DELAY + 1),
|
||||
dt_util.utcnow() + timedelta(seconds=ADVANTAGE_AIR_SYNC_INTERVAL + 1),
|
||||
)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
assert len(mock_get.mock_calls) == 1
|
||||
|
||||
async_fire_time_changed(
|
||||
hass,
|
||||
dt_util.utcnow() + timedelta(seconds=RELOAD_AFTER_UPDATE_DELAY + 1),
|
||||
)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
assert len(mock_get.mock_calls) == 2
|
||||
|
||||
state = hass.states.get(entity_id)
|
||||
assert state
|
||||
assert state.state == STATE_ON
|
||||
@ -96,6 +104,13 @@ async def test_binary_sensor_async_setup_entry(
|
||||
entity_registry.async_update_entity(entity_id=entity_id, disabled_by=None)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
async_fire_time_changed(
|
||||
hass,
|
||||
dt_util.utcnow() + timedelta(seconds=ADVANTAGE_AIR_SYNC_INTERVAL + 1),
|
||||
)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
assert len(mock_get.mock_calls) == 1
|
||||
|
||||
async_fire_time_changed(
|
||||
hass,
|
||||
dt_util.utcnow() + timedelta(seconds=RELOAD_AFTER_UPDATE_DELAY + 1),
|
||||
|
@ -3,6 +3,7 @@
|
||||
from datetime import timedelta
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from homeassistant.components.advantage_air import ADVANTAGE_AIR_SYNC_INTERVAL
|
||||
from homeassistant.components.advantage_air.const import DOMAIN as ADVANTAGE_AIR_DOMAIN
|
||||
from homeassistant.components.advantage_air.sensor import (
|
||||
ADVANTAGE_AIR_SERVICE_SET_TIME_TO,
|
||||
@ -123,16 +124,23 @@ async def test_sensor_platform_disabled_entity(
|
||||
|
||||
assert not hass.states.get(entity_id)
|
||||
|
||||
mock_get.reset_mock()
|
||||
entity_registry.async_update_entity(entity_id=entity_id, disabled_by=None)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
mock_get.reset_mock()
|
||||
|
||||
async_fire_time_changed(
|
||||
hass,
|
||||
dt_util.utcnow() + timedelta(seconds=ADVANTAGE_AIR_SYNC_INTERVAL + 1),
|
||||
)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
assert len(mock_get.mock_calls) == 1
|
||||
|
||||
async_fire_time_changed(
|
||||
hass,
|
||||
dt_util.utcnow() + timedelta(seconds=RELOAD_AFTER_UPDATE_DELAY + 1),
|
||||
)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
assert len(mock_get.mock_calls) == 1
|
||||
assert len(mock_get.mock_calls) == 2
|
||||
|
||||
state = hass.states.get(entity_id)
|
||||
assert state
|
||||
|
Loading…
x
Reference in New Issue
Block a user