tests: stop the cloud write test leaving a debounced refresh behind
A write schedules a debounced refresh, which polled through a fake session that only implements post(), crashed on the missing get(), and left its timer running past the end of the test. CI's lingering-timer check caught it; it passed locally only by timing luck. Stubbed the same way test_coordinator_send_command's fixture already does, which is what this test should have copied to begin with.
This commit is contained in:
1 file changed
+8
@@ -13,6 +13,7 @@ import asyncio
|
|||||||
import contextlib
|
import contextlib
|
||||||
import json
|
import json
|
||||||
from typing import Any, cast
|
from typing import Any, cast
|
||||||
|
from unittest.mock import AsyncMock
|
||||||
|
|
||||||
import cbor2
|
import cbor2
|
||||||
import pytest
|
import pytest
|
||||||
@@ -164,7 +165,14 @@ async def test_selecting_a_named_program_writes_both_tokens(hass: HomeAssistant)
|
|||||||
sent.append((path_segs, payload))
|
sent.append((path_segs, payload))
|
||||||
return 0x44, b""
|
return 0x44, b""
|
||||||
|
|
||||||
|
def pace(self):
|
||||||
|
pass
|
||||||
|
|
||||||
coordinator._session = cast(Any, _FakeSession())
|
coordinator._session = cast(Any, _FakeSession())
|
||||||
|
# Same shape as test_coordinator_send_command's fixture: a write schedules
|
||||||
|
# a debounced refresh, which would poll through this fake and leave its
|
||||||
|
# timer behind after the test.
|
||||||
|
coordinator.async_request_refresh = AsyncMock()
|
||||||
bound = next(b for b in coordinator.bound if b.desc.key == "cycle")
|
bound = next(b for b in coordinator.bound if b.desc.key == "cycle")
|
||||||
await coordinator.async_send_command(bound, "cloud:55")
|
await coordinator.async_send_command(bound, "cloud:55")
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user