mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Fix flaky tests in advantage_air (#129758)
This commit is contained in:
parent
c2ef119e50
commit
f11aba9648
@ -1,10 +1,8 @@
|
|||||||
"""Test the Advantage Air Binary Sensor Platform."""
|
"""Test the Advantage Air Binary Sensor Platform."""
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from unittest.mock import AsyncMock
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
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.const import STATE_OFF, STATE_ON
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import entity_registry as er
|
||||||
@ -70,22 +68,14 @@ async def test_binary_sensor_async_setup_entry(
|
|||||||
assert not hass.states.get(entity_id)
|
assert not hass.states.get(entity_id)
|
||||||
|
|
||||||
mock_get.reset_mock()
|
mock_get.reset_mock()
|
||||||
entity_registry.async_update_entity(entity_id=entity_id, disabled_by=None)
|
|
||||||
await hass.async_block_till_done()
|
|
||||||
|
|
||||||
async_fire_time_changed(
|
with patch("homeassistant.config_entries.RELOAD_AFTER_UPDATE_DELAY", 1):
|
||||||
hass,
|
entity_registry.async_update_entity(entity_id=entity_id, disabled_by=None)
|
||||||
dt_util.utcnow() + timedelta(seconds=ADVANTAGE_AIR_SYNC_INTERVAL + 1),
|
await hass.async_block_till_done()
|
||||||
)
|
|
||||||
await hass.async_block_till_done(wait_background_tasks=True)
|
|
||||||
assert len(mock_get.mock_calls) == 1
|
|
||||||
|
|
||||||
async_fire_time_changed(
|
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(seconds=2))
|
||||||
hass,
|
await hass.async_block_till_done(wait_background_tasks=True)
|
||||||
dt_util.utcnow() + timedelta(seconds=RELOAD_AFTER_UPDATE_DELAY + 1),
|
assert len(mock_get.mock_calls) == 1
|
||||||
)
|
|
||||||
await hass.async_block_till_done(wait_background_tasks=True)
|
|
||||||
assert len(mock_get.mock_calls) == 3
|
|
||||||
|
|
||||||
state = hass.states.get(entity_id)
|
state = hass.states.get(entity_id)
|
||||||
assert state
|
assert state
|
||||||
@ -101,22 +91,14 @@ async def test_binary_sensor_async_setup_entry(
|
|||||||
assert not hass.states.get(entity_id)
|
assert not hass.states.get(entity_id)
|
||||||
|
|
||||||
mock_get.reset_mock()
|
mock_get.reset_mock()
|
||||||
entity_registry.async_update_entity(entity_id=entity_id, disabled_by=None)
|
|
||||||
await hass.async_block_till_done()
|
|
||||||
|
|
||||||
async_fire_time_changed(
|
with patch("homeassistant.config_entries.RELOAD_AFTER_UPDATE_DELAY", 1):
|
||||||
hass,
|
entity_registry.async_update_entity(entity_id=entity_id, disabled_by=None)
|
||||||
dt_util.utcnow() + timedelta(seconds=ADVANTAGE_AIR_SYNC_INTERVAL + 1),
|
await hass.async_block_till_done()
|
||||||
)
|
|
||||||
await hass.async_block_till_done(wait_background_tasks=True)
|
|
||||||
assert len(mock_get.mock_calls) == 1
|
|
||||||
|
|
||||||
async_fire_time_changed(
|
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(seconds=2))
|
||||||
hass,
|
await hass.async_block_till_done(wait_background_tasks=True)
|
||||||
dt_util.utcnow() + timedelta(seconds=RELOAD_AFTER_UPDATE_DELAY + 1),
|
assert len(mock_get.mock_calls) == 1
|
||||||
)
|
|
||||||
await hass.async_block_till_done(wait_background_tasks=True)
|
|
||||||
assert len(mock_get.mock_calls) == 3
|
|
||||||
|
|
||||||
state = hass.states.get(entity_id)
|
state = hass.states.get(entity_id)
|
||||||
assert state
|
assert state
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
"""Test the Advantage Air Sensor Platform."""
|
"""Test the Advantage Air Sensor Platform."""
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from unittest.mock import AsyncMock
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
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.const import DOMAIN as ADVANTAGE_AIR_DOMAIN
|
||||||
from homeassistant.components.advantage_air.sensor import (
|
from homeassistant.components.advantage_air.sensor import (
|
||||||
ADVANTAGE_AIR_SERVICE_SET_TIME_TO,
|
ADVANTAGE_AIR_SERVICE_SET_TIME_TO,
|
||||||
ADVANTAGE_AIR_SET_COUNTDOWN_VALUE,
|
ADVANTAGE_AIR_SET_COUNTDOWN_VALUE,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import RELOAD_AFTER_UPDATE_DELAY
|
|
||||||
from homeassistant.const import ATTR_ENTITY_ID
|
from homeassistant.const import ATTR_ENTITY_ID
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import entity_registry as er
|
||||||
@ -124,23 +122,15 @@ async def test_sensor_platform_disabled_entity(
|
|||||||
|
|
||||||
assert not hass.states.get(entity_id)
|
assert not hass.states.get(entity_id)
|
||||||
|
|
||||||
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()
|
mock_get.reset_mock()
|
||||||
|
|
||||||
async_fire_time_changed(
|
with patch("homeassistant.config_entries.RELOAD_AFTER_UPDATE_DELAY", 1):
|
||||||
hass,
|
entity_registry.async_update_entity(entity_id=entity_id, disabled_by=None)
|
||||||
dt_util.utcnow() + timedelta(seconds=ADVANTAGE_AIR_SYNC_INTERVAL + 1),
|
await hass.async_block_till_done(wait_background_tasks=True)
|
||||||
)
|
|
||||||
await hass.async_block_till_done(wait_background_tasks=True)
|
|
||||||
assert len(mock_get.mock_calls) == 1
|
|
||||||
|
|
||||||
async_fire_time_changed(
|
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(seconds=2))
|
||||||
hass,
|
await hass.async_block_till_done(wait_background_tasks=True)
|
||||||
dt_util.utcnow() + timedelta(seconds=RELOAD_AFTER_UPDATE_DELAY + 1),
|
assert len(mock_get.mock_calls) == 1
|
||||||
)
|
|
||||||
await hass.async_block_till_done(wait_background_tasks=True)
|
|
||||||
assert len(mock_get.mock_calls) == 3
|
|
||||||
|
|
||||||
state = hass.states.get(entity_id)
|
state = hass.states.get(entity_id)
|
||||||
assert state
|
assert state
|
||||||
|
Loading…
x
Reference in New Issue
Block a user