@@ -58,15 +58,20 @@ def maps_trait(device: RoborockDevice) -> MapsTrait:
5858async def test_refresh_maps_trait (
5959 maps_trait : MapsTrait ,
6060 mock_rpc_channel : AsyncMock ,
61+ mock_mqtt_rpc_channel : AsyncMock ,
6162 status_trait : StatusTrait ,
6263) -> None :
6364 """Test successfully getting multi maps list."""
6465 # Setup mock to return the sample multi maps list
6566 mock_rpc_channel .send_command .side_effect = [
6667 mock_data .STATUS , # Initial status fetch
68+ ]
69+ mock_mqtt_rpc_channel .send_command .side_effect = [
6770 MULTI_MAP_LIST_DATA ,
6871 ]
6972 await status_trait .refresh ()
73+ assert status_trait .current_map == 0
74+
7075 # Populating the status information gives us the current map
7176 # flag, but we have not loaded the rest of the information.
7277 assert maps_trait .current_map == 0
@@ -96,22 +101,27 @@ async def test_refresh_maps_trait(
96101 assert maps_trait .current_map_info .name == "Map 1"
97102
98103 # Verify the RPC call was made correctly
99- assert mock_rpc_channel .send_command .call_count == 2
104+ assert mock_rpc_channel .send_command .call_count == 1
100105 mock_rpc_channel .send_command .assert_any_call (RoborockCommand .GET_STATUS )
101- mock_rpc_channel .send_command .assert_any_call (RoborockCommand .GET_MULTI_MAPS_LIST )
106+ assert mock_mqtt_rpc_channel .send_command .call_count == 1
107+ mock_mqtt_rpc_channel .send_command .assert_any_call (RoborockCommand .GET_MULTI_MAPS_LIST )
102108
103109
104110async def test_set_current_map (
105111 status_trait : StatusTrait ,
106112 maps_trait : MapsTrait ,
107113 mock_rpc_channel : AsyncMock ,
114+ mock_mqtt_rpc_channel : AsyncMock ,
108115) -> None :
109116 """Test successfully setting the current map."""
117+ assert hasattr (maps_trait , "mqtt_rpc_channel" )
110118 mock_rpc_channel .send_command .side_effect = [
111119 mock_data .STATUS , # Initial status fetch
120+ UPDATED_STATUS , # Response for refreshing status
121+ ]
122+ mock_mqtt_rpc_channel .send_command .side_effect = [
112123 MULTI_MAP_LIST_DATA , # Response for LOAD_MULTI_MAP
113124 {}, # Response for setting the current map
114- UPDATED_STATUS , # Response for refreshing status
115125 ]
116126 await status_trait .refresh ()
117127
@@ -139,7 +149,8 @@ async def test_set_current_map(
139149 # 2. GET_MULTI_MAPS_LIST to get the map list
140150 # 3. LOAD_MULTI_MAP to set the map
141151 # 4. GET_STATUS to refresh the current map in status
142- assert mock_rpc_channel .send_command .call_count == 4
152+ assert mock_rpc_channel .send_command .call_count == 2
143153 mock_rpc_channel .send_command .assert_any_call (RoborockCommand .GET_STATUS )
144- mock_rpc_channel .send_command .assert_any_call (RoborockCommand .GET_MULTI_MAPS_LIST )
145- mock_rpc_channel .send_command .assert_any_call (RoborockCommand .LOAD_MULTI_MAP , params = [123 ])
154+ assert mock_mqtt_rpc_channel .send_command .call_count == 2
155+ mock_mqtt_rpc_channel .send_command .assert_any_call (RoborockCommand .GET_MULTI_MAPS_LIST )
156+ mock_mqtt_rpc_channel .send_command .assert_any_call (RoborockCommand .LOAD_MULTI_MAP , params = [123 ])
0 commit comments