1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-20 10:43:48 +01:00

Fix flaky test_api_conditional_memory and improve integration test patterns (#9379)

This commit is contained in:
J. Nick Koston
2025-07-07 18:08:21 -05:00
committed by GitHub
parent 7150f2806f
commit a72905191a
11 changed files with 341 additions and 234 deletions

View File

@@ -4,7 +4,7 @@ from __future__ import annotations
import asyncio
from aioesphomeapi import EntityState
from aioesphomeapi import EntityState, SensorState
import pytest
from .types import APIClientConnectedFactory, RunCompiledFunction
@@ -30,7 +30,7 @@ async def test_host_mode_many_entities(
sensor_states = [
s
for s in states.values()
if hasattr(s, "state") and isinstance(s.state, float)
if isinstance(s, SensorState) and isinstance(s.state, float)
]
# When we have received states from at least 50 sensors, resolve the future
if len(sensor_states) >= 50 and not sensor_count_future.done():
@@ -45,7 +45,7 @@ async def test_host_mode_many_entities(
sensor_states = [
s
for s in states.values()
if hasattr(s, "state") and isinstance(s.state, float)
if isinstance(s, SensorState) and isinstance(s.state, float)
]
pytest.fail(
f"Did not receive states from at least 50 sensors within 10 seconds. "
@@ -61,7 +61,7 @@ async def test_host_mode_many_entities(
sensor_states = [
s
for s in states.values()
if hasattr(s, "state") and isinstance(s.state, float)
if isinstance(s, SensorState) and isinstance(s.state, float)
]
assert sensor_count >= 50, (