mirror of
https://github.com/esphome/esphome.git
synced 2026-09-11 23:37:34 +00:00
enforce buffer size safety at compile time
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user