From 37a3089da8bab044d95b2efd56fbfa2abaf1994a Mon Sep 17 00:00:00 2001 From: Erwin Douna Date: Thu, 8 Oct 2026 23:06:47 +0200 Subject: [PATCH] Use freezer instead of coordinator refresh in reolink tests (#185080) --- tests/components/reolink/test_update.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/components/reolink/test_update.py b/tests/components/reolink/test_update.py index 6992db163de0..27f76f2601ec 100644 --- a/tests/components/reolink/test_update.py +++ b/tests/components/reolink/test_update.py @@ -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