29
29
TEST_SECURITY_DATA = SecurityData (endpoint = "test_endpoint" , nonce = b"test_nonce_16byte" )
30
30
TEST_HOST = "1.1.1.1"
31
31
32
+
32
33
@dataclass
33
34
class FakeResponse (RoborockBase ):
34
35
state : str
@@ -330,22 +331,22 @@ async def test_v1_channel_subscription_receives_mqtt_messages(
330
331
) -> None :
331
332
"""Test that subscribed callback receives MQTT messages."""
332
333
callback = Mock ()
333
-
334
+
334
335
# Setup MQTT subscription to capture the internal callback
335
336
mock_mqtt_channel .subscribe .return_value = Mock ()
336
337
mock_local_channel .connect .side_effect = RoborockException ("Local failed" )
337
-
338
+
338
339
# Subscribe
339
340
with patch .object (v1_channel , "_get_networking_info" , return_value = TEST_NETWORKING_INFO ):
340
341
await v1_channel .subscribe (callback )
341
-
342
+
342
343
# Get the MQTT callback that was registered
343
344
mqtt_callback = mock_mqtt_channel .subscribe .call_args [0 ][0 ]
344
-
345
+
345
346
# Simulate MQTT message
346
347
test_message = TEST_RESPONSE
347
348
mqtt_callback (test_message )
348
-
349
+
349
350
# Verify user callback was called
350
351
callback .assert_called_once_with (test_message )
351
352
@@ -357,22 +358,22 @@ async def test_v1_channel_subscription_receives_local_messages(
357
358
) -> None :
358
359
"""Test that subscribed callback receives local messages."""
359
360
callback = Mock ()
360
-
361
+
361
362
# Setup both connections
362
363
mock_mqtt_channel .subscribe .return_value = Mock ()
363
364
mock_local_channel .subscribe .return_value = Mock ()
364
-
365
+
365
366
# Subscribe
366
367
with patch .object (v1_channel , "_get_networking_info" , return_value = TEST_NETWORKING_INFO ):
367
368
await v1_channel .subscribe (callback )
368
-
369
+
369
370
# Get the local callback that was registered
370
371
local_callback = mock_local_channel .subscribe .call_args [0 ][0 ]
371
-
372
+
372
373
# Simulate local message
373
374
test_message = TEST_RESPONSE
374
375
local_callback (test_message )
375
-
376
+
376
377
# Verify user callback was called
377
378
callback .assert_called_once_with (test_message )
378
379
@@ -401,10 +402,10 @@ async def test_v1_channel_networking_info_retrieved_during_connection(
401
402
# Verify both connections are established
402
403
assert v1_channel .is_mqtt_connected
403
404
assert v1_channel .is_local_connected
404
-
405
+
405
406
# Verify network info was requested via MQTT
406
407
mock_mqtt_channel .send_command .assert_called_once ()
407
-
408
+
408
409
# Verify local session was created with the correct IP
409
410
mock_local_session .assert_called_once_with (mock_data .NETWORK_INFO ["ip" ])
410
411
0 commit comments