Skip to content

Commit 9f606d0

Browse files
committed
chore: Split up test_containers.py into data subdirectories
Split up the existing containers test into tests for the protocol specific subdirectories, following the newr roborock.data module structure. This also updates all mock_data references to reference the tests path rather than a relative path.
1 parent 7e40857 commit 9f606d0

File tree

10 files changed

+669
-654
lines changed

10 files changed

+669
-654
lines changed
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
"""Test cases for the containers module."""
2+
3+
from roborock.data.b01_q7 import (
4+
B01Fault,
5+
B01Props,
6+
SCWindMapping,
7+
WorkStatusMapping,
8+
)
9+
10+
11+
def test_b01props_deserialization():
12+
"""Test that B01Props can be deserialized after its module is dynamically imported."""
13+
14+
B01_PROPS_MOCK_DATA = {
15+
"status": 6,
16+
"fault": 510,
17+
"wind": 3,
18+
"water": 2,
19+
"mode": 1,
20+
"quantity": 1,
21+
"alarm": 0,
22+
"volume": 60,
23+
"hypa": 90,
24+
"mainBrush": 80,
25+
"sideBrush": 70,
26+
"mopLife": 60,
27+
"mainSensor": 50,
28+
"netStatus": {
29+
"rssi": "-60",
30+
"loss": 1,
31+
"ping": 20,
32+
"ip": "192.168.1.102",
33+
"mac": "BB:CC:DD:EE:FF:00",
34+
"ssid": "MyOtherWiFi",
35+
"frequency": 2.4,
36+
"bssid": "00:FF:EE:DD:CC:BB",
37+
},
38+
"repeatState": 1,
39+
"tankState": 0,
40+
"sweepType": 0,
41+
"cleanPathPreference": 1,
42+
"clothState": 1,
43+
"timeZone": -5,
44+
"timeZoneInfo": "America/New_York",
45+
"language": 2,
46+
"cleaningTime": 1500,
47+
"realCleanTime": 1400,
48+
"cleaningArea": 600000,
49+
"customType": 1,
50+
"sound": 0,
51+
"workMode": 3,
52+
"stationAct": 1,
53+
"chargeState": 0,
54+
"currentMapId": 2,
55+
"mapNum": 3,
56+
"dustAction": 0,
57+
"quietIsOpen": 1,
58+
"quietBeginTime": 23,
59+
"quietEndTime": 7,
60+
"cleanFinish": 0,
61+
"voiceType": 2,
62+
"voiceTypeVersion": 1,
63+
"orderTotal": {"total": 12, "enable": 0},
64+
"buildMap": 0,
65+
"privacy": {
66+
"aiRecognize": 1,
67+
"dirtRecognize": 1,
68+
"petRecognize": 1,
69+
"carpetTurbo": 1,
70+
"carpetAvoid": 1,
71+
"carpetShow": 1,
72+
"mapUploads": 1,
73+
"aiAgent": 1,
74+
"aiAvoidance": 1,
75+
"recordUploads": 1,
76+
"alongFloor": 1,
77+
"autoUpgrade": 1,
78+
},
79+
"dustAutoState": 0,
80+
"dustFrequency": 1,
81+
"childLock": 1,
82+
"multiFloor": 0,
83+
"mapSave": 0,
84+
"lightMode": 0,
85+
"greenLaser": 0,
86+
"dustBagUsed": 1,
87+
"orderSaveMode": 0,
88+
"manufacturer": "Roborock-Test",
89+
"backToWash": 0,
90+
"chargeStationType": 2,
91+
"pvCutCharge": 1,
92+
"pvCharging": {"status": 1, "beginTime": 10, "endTime": 18},
93+
"serialNumber": "987654321",
94+
"recommend": {"sill": 0, "wall": 0, "roomId": [4, 5, 6]},
95+
"addSweepStatus": 1,
96+
}
97+
98+
deserialized = B01Props.from_dict(B01_PROPS_MOCK_DATA)
99+
assert isinstance(deserialized, B01Props)
100+
assert deserialized.fault == B01Fault.F_510
101+
assert deserialized.status == WorkStatusMapping.SWEEP_MOPING_2
102+
assert deserialized.wind == SCWindMapping.SUPER_STRONG
103+
assert deserialized.net_status is not None
104+
assert deserialized.net_status.ip == "192.168.1.102"

0 commit comments

Comments
 (0)