99
1010from roborock .containers import HomeData , S7MaxVStatus , UserData
1111from roborock .devices .device import RoborockDevice
12- from roborock .devices .traits import Trait
13- from roborock .devices .traits .v1 import create_v1_traits
12+ from roborock .devices .traits import v1
1413from roborock .devices .traits .v1 .common import V1TraitMixin
1514from roborock .devices .v1_rpc_channel import decode_rpc_response
1615from roborock .roborock_message import RoborockMessage , RoborockMessageProtocol
@@ -37,21 +36,15 @@ def rpc_channel_fixture() -> AsyncMock:
3736
3837
3938@pytest .fixture (autouse = True , name = "device" )
40- def device_fixture (channel : AsyncMock , traits : list [ Trait ] ) -> RoborockDevice :
39+ def device_fixture (channel : AsyncMock , rpc_channel : AsyncMock ) -> RoborockDevice :
4140 """Fixture to set up the device for tests."""
4241 return RoborockDevice (
4342 device_info = HOME_DATA .devices [0 ],
4443 channel = channel ,
45- traits = traits ,
44+ trait = v1 . create ( HOME_DATA . products [ 0 ], rpc_channel ) ,
4645 )
4746
4847
49- @pytest .fixture (autouse = True , name = "traits" )
50- def traits_fixture (rpc_channel : AsyncMock ) -> list [Trait ]:
51- """Fixture to set up the V1 API for tests."""
52- return create_v1_traits (HOME_DATA .products [0 ], rpc_channel )
53-
54-
5548async def test_device_connection (device : RoborockDevice , channel : AsyncMock ) -> None :
5649 """Test the Device connection setup."""
5750
@@ -91,7 +84,7 @@ def setup_rpc_channel_fixture(rpc_channel: AsyncMock, payload: pathlib.Path) ->
9184
9285
9386@pytest .mark .parametrize (
94- ("payload" , "trait_method " ),
87+ ("payload" , "property_method " ),
9588 [
9689 (TESTDATA / "get_status.json" , lambda x : x .status ),
9790 (TESTDATA / "get_dnd.json" , lambda x : x .dnd ),
@@ -103,11 +96,11 @@ async def test_device_trait_command_parsing(
10396 device : RoborockDevice ,
10497 setup_rpc_channel : AsyncMock ,
10598 snapshot : SnapshotAssertion ,
106- trait_method : Callable [..., V1TraitMixin ],
99+ property_method : Callable [..., V1TraitMixin ],
107100 payload : str ,
108101) -> None :
109102 """Test the device trait command."""
110- trait = trait_method (device .v1_properties )
103+ trait = property_method (device .v1_properties )
111104 assert trait
112105 assert isinstance (trait , V1TraitMixin )
113106 await trait .refresh ()
0 commit comments