Disable the aiohttp total timeout on the panel SSE stream (task 6c4b0fa4)

Home Assistant's shared session defaults to ClientTimeout(total=300),
which cut a healthy event stream every five minutes; transitions fired
during the reconnect window are not replayed. The stream request now
passes ClientTimeout(total=None, sock_connect=<client timeout>), with
aiohttp imported lazily so the client stays importable without it.
Tests run the stream path against a stand-in aiohttp module fixture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-06 08:54:49 -04:00
co-authored by Claude Opus 5.5
parent 0ccf787dc6
commit b4e96adf9c
4 changed files with 76 additions and 6 deletions
+23
View File
@@ -879,6 +879,29 @@ def set_coordinator_client(entry, client):
return client
@dataclass(frozen=True)
class FakeClientTimeout:
"""Stand-in for ``aiohttp.ClientTimeout`` (the fields the client sets)."""
total: float | None = None
sock_connect: float | None = None
@pytest.fixture
def fake_aiohttp(monkeypatch):
"""Install a stand-in ``aiohttp`` module for one test.
aiohttp ships only with Home Assistant, so this mock-only harness
does not have it; the API client imports it lazily inside
``stream_events`` (for ``ClientTimeout``). Tests driving the real
stream path request this fixture; the module is removed again when
the test ends.
"""
module = SimpleNamespace(ClientTimeout=FakeClientTimeout)
monkeypatch.setitem(sys.modules, "aiohttp", module)
return module
@pytest.fixture(autouse=True)
def coordinator_client_from_test_override():
"""Resolve every entry's coordinator client through the test seam.