@@ -234,13 +234,13 @@ async def test_v1_channel_send_decoded_command_local_preferred(
234234 assert result .state == RoborockStateCode .cleaning
235235
236236
237- async def test_v1_channel_send_decoded_command_fallback_to_mqtt (
237+ async def test_v1_channel_send_decoded_command_local_fails (
238238 v1_channel : V1Channel ,
239239 mock_mqtt_channel : Mock ,
240240 mock_local_channel : Mock ,
241241 mqtt_responses : list [RoborockMessage ],
242242) -> None :
243- """Test command sending falls back to MQTT when local fails."""
243+ """Test case where sending with local connection fails."""
244244
245245 # Establish connections
246246 await v1_channel .subscribe (Mock ())
@@ -251,15 +251,15 @@ async def test_v1_channel_send_decoded_command_fallback_to_mqtt(
251251
252252 # Send command
253253 mqtt_responses .append (TEST_RESPONSE )
254- result = await v1_channel .send_decoded_command (
255- RoborockCommand .CHANGE_SOUND_VOLUME ,
256- response_type = S5MaxStatus ,
257- )
254+ with pytest .raises (RoborockException , match = "Local failed" ):
255+ await v1_channel .send_decoded_command (
256+ RoborockCommand .CHANGE_SOUND_VOLUME ,
257+ response_type = S5MaxStatus ,
258+ )
258259
259- # Verify both were attempted
260+ # Verify local was attempted but not mqtt
260261 mock_local_channel .send_command .assert_called_once ()
261- mock_mqtt_channel .send_command .assert_called_once ()
262- assert result .state == RoborockStateCode .cleaning
262+ mock_mqtt_channel .send_command .assert_not_called ()
263263
264264
265265async def test_v1_channel_send_decoded_command_mqtt_only (
@@ -531,38 +531,3 @@ async def test_v1_channel_full_subscribe_and_command_flow(
531531 unsub ()
532532 mqtt_unsub .assert_called_once ()
533533 local_unsub .assert_called_once ()
534-
535-
536- async def test_v1_channel_graceful_degradation_local_to_mqtt (
537- mock_mqtt_channel : Mock ,
538- mock_local_session : Mock ,
539- mock_local_channel : Mock ,
540- mqtt_responses : list [RoborockMessage ],
541- ) -> None :
542- """Test graceful degradation from local to MQTT during operation."""
543- v1_channel = V1Channel (
544- device_uid = TEST_DEVICE_UID ,
545- security_data = TEST_SECURITY_DATA ,
546- mqtt_channel = mock_mqtt_channel ,
547- local_session = mock_local_session ,
548- )
549-
550- await v1_channel .subscribe (Mock ())
551- mock_mqtt_channel .send_command .reset_mock (return_value = False )
552-
553- # First command: local works
554- mock_local_channel .send_command .return_value = TEST_RESPONSE
555- result1 = await v1_channel .send_decoded_command (RoborockCommand .GET_STATUS , response_type = S5MaxStatus )
556- assert result1 .state == RoborockStateCode .cleaning
557- mock_local_channel .send_command .assert_called_once ()
558- mock_mqtt_channel .send_command .assert_not_called ()
559-
560- # Second command: local fails, falls back to MQTT
561- mock_local_channel .send_command .side_effect = RoborockException ("Local failed" )
562- mqtt_responses .append (TEST_RESPONSE )
563- result2 = await v1_channel .send_decoded_command (RoborockCommand .GET_STATUS , response_type = S5MaxStatus )
564- assert result2 .state == RoborockStateCode .cleaning
565-
566- # Verify both were attempted
567- assert mock_local_channel .send_command .call_count == 2
568- mock_mqtt_channel .send_command .assert_called_once ()
0 commit comments