33from unittest .mock import AsyncMock
44
55import pytest
6+ from typing import Any
67
78from roborock .devices .device import RoborockDevice
89from roborock .devices .traits .v1 .rooms import RoomsTrait
910from roborock .devices .traits .v1 .status import StatusTrait
1011from roborock .roborock_typing import RoborockCommand
1112
12- # Rooms from mock_data.HOME_DATA
13- # {"id": 2362048, "name": "Example room 1"},
14- # {"id": 2362044, "name": "Example room 2"},
15- # {"id": 2362041, "name": "Example room 3"},
16- ROOM_MAPPING_DATA = [[16 , "2362048" ], [17 , "2362044" ], [18 , "2362041" ]]
17-
1813
1914@pytest .fixture
2015def status_trait (device : RoborockDevice ) -> StatusTrait :
@@ -30,15 +25,25 @@ def rooms_trait(device: RoborockDevice) -> RoomsTrait:
3025 return device .v1_properties .rooms
3126
3227
28+ # Rooms from mock_data.HOME_DATA
29+ # {"id": 2362048, "name": "Example room 1"},
30+ # {"id": 2362044, "name": "Example room 2"},
31+ # {"id": 2362041, "name": "Example room 3"},
32+ @pytest .mark .parametrize (
33+ ("room_mapping_data" ),
34+ [
35+ ([[16 , "2362048" ], [17 , "2362044" ], [18 , "2362041" ]]),
36+ ([[16 , "2362048" , 6 ], [17 , "2362044" , 14 ], [18 , "2362041" , 13 ]]),
37+ ]
38+ )
3339async def test_refresh_rooms_trait (
3440 rooms_trait : RoomsTrait ,
3541 mock_rpc_channel : AsyncMock ,
42+ room_mapping_data : list [Any ],
3643) -> None :
3744 """Test successfully getting room mapping."""
3845 # Setup mock to return the sample room mapping
39- mock_rpc_channel .send_command .side_effect = [
40- ROOM_MAPPING_DATA ,
41- ]
46+ mock_rpc_channel .send_command .side_effect = [room_mapping_data ]
4247 # Before refresh, rooms should be empty
4348 assert not rooms_trait .rooms
4449
0 commit comments