Skip to content

Commit 4e5e85e

Browse files
Fix linting in test_v1_channel_reconnect.py
1 parent a8a079e commit 4e5e85e

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

tests/devices/test_v1_channel_reconnect.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
2-
import asyncio
31
import datetime
4-
import logging
5-
from unittest.mock import AsyncMock, Mock, patch
2+
from unittest.mock import AsyncMock, Mock
63

74
import pytest
85

96
from roborock.data import NetworkInfo
107
from roborock.devices.cache import CacheData, InMemoryCache
118
from roborock.devices.local_channel import LocalSession
12-
from roborock.devices.v1_channel import V1Channel, NETWORK_INFO_REFRESH_INTERVAL
9+
from roborock.devices.v1_channel import NETWORK_INFO_REFRESH_INTERVAL, V1Channel
1310
from roborock.exceptions import RoborockException
1411
from roborock.protocols.v1_protocol import SecurityData
1512

@@ -19,6 +16,7 @@
1916
TEST_SECURITY_DATA = SecurityData(endpoint="test_endpoint", nonce=b"test_nonce")
2017
TEST_IP = "192.168.1.100"
2118

19+
2220
@pytest.fixture(name="mock_mqtt_channel")
2321
async def setup_mock_mqtt_channel() -> FakeChannel:
2422
"""Mock MQTT channel for testing."""
@@ -28,19 +26,22 @@ async def setup_mock_mqtt_channel() -> FakeChannel:
2826
channel.send_command = AsyncMock(side_effect=RoborockException("MQTT Failed"))
2927
return channel
3028

29+
3130
@pytest.fixture(name="mock_local_channel")
3231
async def setup_mock_local_channel() -> FakeChannel:
3332
"""Mock Local channel for testing."""
3433
channel = FakeChannel()
3534
return channel
3635

36+
3737
@pytest.fixture(name="mock_local_session")
3838
def setup_mock_local_session(mock_local_channel: Mock) -> Mock:
3939
"""Mock Local session factory for testing."""
4040
mock_session = Mock(spec=LocalSession)
4141
mock_session.return_value = mock_local_channel
4242
return mock_session
4343

44+
4445
@pytest.mark.asyncio
4546
async def test_v1_channel_reconnect_with_stale_cache_and_mqtt_down(
4647
mock_mqtt_channel: FakeChannel,
@@ -67,7 +68,9 @@ async def test_v1_channel_reconnect_with_stale_cache_and_mqtt_down(
6768
)
6869

6970
# Manually set the last refresh to be old to simulate stale cache
70-
v1_channel._last_network_info_refresh = datetime.datetime.now(datetime.UTC) - (NETWORK_INFO_REFRESH_INTERVAL + datetime.timedelta(hours=1))
71+
# Break long line
72+
last_refresh = datetime.datetime.now(datetime.UTC) - (NETWORK_INFO_REFRESH_INTERVAL + datetime.timedelta(hours=1))
73+
v1_channel._last_network_info_refresh = last_refresh
7174

7275
# 2. Mock MQTT RPC channel to fail
7376
# V1Channel creates _mqtt_rpc_channel in __init__. We need to mock its send_command.

0 commit comments

Comments
 (0)