From c73d88ce3352d9c5046364cdaf021e30254b3f82 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 6 Jan 2026 16:36:36 -1000 Subject: [PATCH] enforce buffer size safety at compile time --- tests/integration/test_strftime_to.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/integration/test_strftime_to.py b/tests/integration/test_strftime_to.py index f96161faf4..9220da148b 100644 --- a/tests/integration/test_strftime_to.py +++ b/tests/integration/test_strftime_to.py @@ -7,7 +7,7 @@ import asyncio from aioesphomeapi import EntityState, TextSensorState import pytest -from .state_utils import require_entity +from .state_utils import InitialStateHelper, require_entity from .types import APIClientConnectedFactory, RunCompiledFunction @@ -40,7 +40,7 @@ async def test_strftime_to( entities, "time_error_format", description="Time Error Format sensor" ) - # Wait for all text sensors to have valid states + # Set up state tracking with InitialStateHelper loop = asyncio.get_running_loop() states: dict[int, TextSensorState] = {} all_received = loop.create_future() @@ -50,6 +50,7 @@ async def test_strftime_to( string_format.key, error_format.key, } + initial_state_helper = InitialStateHelper(entities) def on_state(state: EntityState) -> None: if isinstance(state, TextSensorState) and not state.missing_state: @@ -57,8 +58,16 @@ async def test_strftime_to( if expected_keys <= states.keys() and not all_received.done(): all_received.set_result(True) - client.subscribe_states(on_state) + # Subscribe with the wrapper that filters initial states + client.subscribe_states(initial_state_helper.on_state_wrapper(on_state)) + # Wait for initial states to be broadcast + try: + await initial_state_helper.wait_for_initial_states() + except TimeoutError: + pytest.fail("Timeout waiting for initial states") + + # Wait for all expected states try: await asyncio.wait_for(all_received, timeout=5.0) except TimeoutError: