|
1 | 1 | """Tests for the DeviceManager class.""" |
2 | 2 |
|
3 | | -import datetime |
4 | 3 | import asyncio |
| 4 | +import datetime |
5 | 5 | from collections.abc import Generator, Iterator |
6 | 6 | from unittest.mock import AsyncMock, Mock, patch |
7 | 7 |
|
@@ -38,19 +38,20 @@ def channel_fixture() -> Generator[Mock, None, None]: |
38 | 38 |
|
39 | 39 | @pytest.fixture(autouse=True) |
40 | 40 | def mock_sleep() -> Generator[Mock, None, None]: |
41 | | - """Mock asyncio.sleep in device module to speed up tests.""" |
| 41 | + """Mock sleep logic to speed up tests.""" |
42 | 42 | sleep_time = datetime.timedelta(seconds=0.001) |
43 | | - with patch("roborock.devices.device.MIN_BACKOFF_INTERVAL", sleep_time), patch("roborock.devices.device.MAX_BACKOFF_INTERVAL", sleep_time): |
| 43 | + with ( |
| 44 | + patch("roborock.devices.device.MIN_BACKOFF_INTERVAL", sleep_time), |
| 45 | + patch("roborock.devices.device.MAX_BACKOFF_INTERVAL", sleep_time), |
| 46 | + ): |
44 | 47 | yield |
45 | 48 |
|
46 | 49 |
|
47 | 50 | @pytest.fixture(name="channel_failure") |
48 | 51 | def channel_failure_fixture() -> Generator[Mock, None, None]: |
49 | 52 | """Fixture that makes channel subscribe fail.""" |
50 | 53 | with patch("roborock.devices.device_manager.create_v1_channel") as mock_channel: |
51 | | - mock_channel.return_value.subscribe = AsyncMock( |
52 | | - side_effect=RoborockException("Connection failed") |
53 | | - ) |
| 54 | + mock_channel.return_value.subscribe = AsyncMock(side_effect=RoborockException("Connection failed")) |
54 | 55 | mock_channel.return_value.is_connected = False |
55 | 56 | yield mock_channel |
56 | 57 |
|
|
0 commit comments