enforce buffer size safety at compile time

This commit is contained in:
J. Nick Koston
2026-01-06 16:36:36 -10:00
parent 04057a59c6
commit c73d88ce33
+12 -3
View File
@@ -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: