Use freezer instead of coordinator refresh in reolink tests (#185080)

This commit is contained in:
Erwin Douna
2026-10-08 23:06:47 +02:00
committed by GitHub
parent e21baff6df
commit 37a3089da8
+10 -5
View File
@@ -10,6 +10,7 @@ from reolink_aio.exceptions import ApiError, ReolinkError
from reolink_aio.software_version import NewSoftwareVersion
from syrupy.assertion import SnapshotAssertion
from homeassistant.components.reolink.coordinator import DEVICE_UPDATE_INTERVAL_MIN
from homeassistant.components.reolink.update import POLL_AFTER_INSTALL, POLL_PROGRESS
from homeassistant.components.update import DOMAIN as UPDATE_DOMAIN, SERVICE_INSTALL
from homeassistant.config_entries import ConfigEntryState
@@ -233,6 +234,7 @@ async def test_external_firmware_update_detected(
hass: HomeAssistant,
config_entry: MockConfigEntry,
reolink_host: MagicMock,
freezer: FrozenDateTimeFactory,
entity_name: str,
) -> None:
"""Test that external firmware updates (via Reolink app) are detected."""
@@ -244,7 +246,11 @@ async def test_external_firmware_update_detected(
)
reolink_host.firmware_update_available.return_value = new_firmware
with patch("homeassistant.components.reolink.PLATFORMS", [Platform.UPDATE]):
# The binary sensors keep the device coordinator polling
with patch(
"homeassistant.components.reolink.PLATFORMS",
[Platform.BINARY_SENSOR, Platform.UPDATE],
):
assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
assert config_entry.state is ConfigEntryState.LOADED
@@ -256,10 +262,9 @@ async def test_external_firmware_update_detected(
reolink_host.camera_sw_version.return_value = "v3.3.0.226_23031644"
reolink_host.firmware_update_available.return_value = False
# Trigger device coordinator update (simulates regular polling)
# pylint: disable-next=home-assistant-tests-coordinator-async-refresh
await config_entry.runtime_data.device_coordinator.async_refresh()
await hass.async_block_till_done()
freezer.tick(DEVICE_UPDATE_INTERVAL_MIN)
async_fire_time_changed(hass)
await hass.async_block_till_done(wait_background_tasks=True)
# The firmware coordinator should have been refreshed, and update should be cleared
assert hass.states.get(entity_id).state == STATE_OFF