mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Allow passing an optional name to async_track_time_interval (#90244)
* Allow passing an optional name to async_track_time_interval This is the same idea as passing a name to asyncio.create_task which makes it easier to track down bugs * more * short * still cannot find it * add a few more * test
This commit is contained in:
@@ -3438,6 +3438,28 @@ async def test_track_time_interval(hass: HomeAssistant) -> None:
|
||||
assert len(specific_runs) == 2
|
||||
|
||||
|
||||
async def test_track_time_interval_name(hass: HomeAssistant) -> None:
|
||||
"""Test tracking time interval name.
|
||||
|
||||
This test is to ensure that when a name is passed to async_track_time_interval,
|
||||
that the name can be found in the TimerHandle when stringified.
|
||||
"""
|
||||
specific_runs = []
|
||||
unique_string = "xZ13"
|
||||
unsub = async_track_time_interval(
|
||||
hass,
|
||||
callback(lambda x: specific_runs.append(x)),
|
||||
timedelta(seconds=10),
|
||||
unique_string,
|
||||
)
|
||||
scheduled = getattr(hass.loop, "_scheduled")
|
||||
assert any(handle for handle in scheduled if unique_string in str(handle))
|
||||
unsub()
|
||||
|
||||
assert all(handle for handle in scheduled if unique_string not in str(handle))
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
async def test_track_sunrise(hass: HomeAssistant) -> None:
|
||||
"""Test track the sunrise."""
|
||||
latitude = 32.87336
|
||||
|
||||
Reference in New Issue
Block a user