Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tests/devices/rpc/test_v1_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,13 +807,19 @@ async def test_v1_channel_subscribe_failure_is_atomic(
v1_channel: V1Channel,
mock_mqtt_channel: FakeChannel,
mock_local_channel: FakeChannel,
device_cache: DeviceCache,
) -> None:
"""A failure partway through subscribe() leaves the channel re-subscribable.

Regression: a failed subscribe() previously leaked the background reconnect
task and a partial subscription, so the next attempt could neither reuse nor
cleanly recreate the channel.
"""
# Pre-populate device cache with network info so local connect is attempted immediately
device_cache_data = await device_cache.get()
device_cache_data.network_info = TEST_NETWORKING_INFO
await device_cache.set(device_cache_data)

# Both transports down: local connect fails and the MQTT subscribe fails.
mock_local_channel.connect.side_effect = RoborockException("local down")
mock_mqtt_channel.subscribe.side_effect = RoborockException("mqtt down")
Expand Down
5 changes: 3 additions & 2 deletions tests/devices/traits/b01/q10/test_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@ def build_q10_message(payload: bytes) -> Q10Message:

async def wait_for_attribute_value(obj: Any, attribute: str, value: Any, timeout: float = 2.0) -> None:
"""Wait for an attribute on an object to reach a specific value."""
for _ in range(int(timeout / 0.1)):
step = 0.005
for _ in range(int(timeout / step)):
if getattr(obj, attribute) == value:
return
await asyncio.sleep(0.1)
await asyncio.sleep(step)
pytest.fail(f"Timeout waiting for {attribute} to become {value} on {obj}")


Expand Down
6 changes: 4 additions & 2 deletions tests/e2e/test_device_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import json
from collections.abc import AsyncGenerator, Awaitable, Callable
from typing import Any
from unittest.mock import patch

import pytest
import syrupy
Expand Down Expand Up @@ -364,8 +365,9 @@ async def test_l01_device(
for payload in local_responses:
local_response_queue.put_nowait(payload)

# Create the device manager
device_manager = await device_manager_factory(TEST_USER_PARAMS)
# Create the device manager with short local timeout for L01 fallback test
with patch("roborock.devices.transport.local_channel._TIMEOUT", 0.05):
device_manager = await device_manager_factory(TEST_USER_PARAMS)

# The mocked Home Data API returns a single v1 device
devices = await device_manager.get_devices()
Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/test_local_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import asyncio
from collections.abc import AsyncGenerator
from unittest.mock import patch

import pytest
import syrupy
Expand Down Expand Up @@ -167,7 +168,8 @@ async def test_l01_session(
)
)

await local_channel.connect()
with patch("roborock.devices.transport.local_channel._TIMEOUT", 0.05):
await local_channel.connect()

assert local_channel.is_connected

Expand Down
Loading