diff --git a/tests/components/teslemetry/test_init.py b/tests/components/teslemetry/test_init.py index f8a6fa58f291..f15858662ab5 100644 --- a/tests/components/teslemetry/test_init.py +++ b/tests/components/teslemetry/test_init.py @@ -4,6 +4,7 @@ import asyncio from collections.abc import AsyncIterator from contextlib import asynccontextmanager from copy import deepcopy +from datetime import timedelta import logging import time from types import MappingProxyType @@ -686,6 +687,18 @@ async def test_energy_history_coordinator_retry_exceptions( # Entry stays loaded - UpdateFailed with retry_after doesn't break the entry assert entry.state is ConfigEntryState.LOADED + # The coordinator staggers its scheduling deliberately, so these ticks + # bracket retry_after with a margin either side rather than sitting on it. + freezer.tick(timedelta(seconds=expected_retry_after - 2)) + async_fire_time_changed(hass) + await hass.async_block_till_done() + assert call_count == 1 + + freezer.tick(timedelta(seconds=3)) + async_fire_time_changed(hass) + await hass.async_block_till_done() + assert call_count == 2 + async def test_live_status_auth_error( hass: HomeAssistant,