Skip to content

Commit 3283fbb

Browse files
committed
fix: Clean up whitespace and improve readability in test_q10_advanced.py
1 parent 67bbeac commit 3283fbb

File tree

1 file changed

+29
-25
lines changed

1 file changed

+29
-25
lines changed

examples/Q10/test_q10_advanced.py

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,24 @@ async def test_basic_commands(vacuum):
4545
print("\n" + "=" * 50)
4646
print("🧪 TESTING BASIC COMMANDS")
4747
print("=" * 50)
48-
48+
4949
commands = [
5050
("Start cleaning", vacuum.start_clean),
5151
("Pause cleaning", vacuum.pause_clean),
5252
("Resume cleaning", vacuum.resume_clean),
5353
("Stop cleaning", vacuum.stop_clean),
5454
("Return to dock", vacuum.return_to_dock),
5555
]
56-
56+
5757
for idx, (name, cmd) in enumerate(commands, 1):
5858
try:
5959
print(f"\n{idx}. Testing: {name}")
6060
await cmd()
61-
print(f" ✅ Command sent successfully!")
61+
print(" ✅ Command sent successfully!")
6262
except Exception as e:
6363
print(f" ❌ Error: {e}")
6464
import traceback
65+
6566
traceback.print_exc()
6667

6768

@@ -70,18 +71,18 @@ async def test_advanced_features(vacuum):
7071
print("\n" + "=" * 50)
7172
print("🚀 TESTING ADVANCED FEATURES")
7273
print("=" * 50)
73-
74+
7475
from roborock.data.b01_q10.b01_q10_code_mappings import B01_Q10_DP
75-
76+
7677
# Test different cleaning modes
7778
print("\n1. Testing different cleaning modes...")
78-
79+
7980
modes = [
8081
("Standard cleaning (cmd=1)", 1),
8182
("Electoral/Area cleaning (cmd=2)", 2),
8283
("Fast map creation (cmd=4)", 4),
8384
]
84-
85+
8586
for mode_name, cmd_value in modes:
8687
try:
8788
# Ask for confirmation for map creation mode
@@ -93,13 +94,13 @@ async def test_advanced_features(vacuum):
9394
if confirm != "yes":
9495
print(" ⏭️ Skipped!")
9596
continue
96-
97+
9798
print(f"\n{mode_name}")
9899
await vacuum._command.send(
99100
command=B01_Q10_DP.START_CLEAN,
100101
params={"cmd": cmd_value},
101102
)
102-
print(f" ✅ Sent!")
103+
print(" ✅ Sent!")
103104
except Exception as e:
104105
print(f" ❌ Error: {e}")
105106

@@ -109,14 +110,14 @@ async def test_device_status(device):
109110
print("\n" + "=" * 50)
110111
print("📊 CHECKING DEVICE STATUS")
111112
print("=" * 50)
112-
113+
113114
try:
114115
# Check if device has properties for status
115116
print(f"\nDevice: {device.name}")
116117
print(f"Product: {device.product.name} ({device.product.model})")
117118
print(f"Connected: {device.is_connected}")
118119
print(f"Local connected: {device.is_local_connected}")
119-
120+
120121
# Try to get status if available
121122
if device.v1_properties and device.v1_properties.status:
122123
print("\n🔍 V1 Status available")
@@ -126,16 +127,17 @@ async def test_device_status(device):
126127
print(f" Status: {status}")
127128
except Exception as e:
128129
print(f" Could not refresh status: {e}")
129-
130+
130131
# Check Q10 properties
131132
if device.b01_q10_properties:
132133
print("\n✅ Q10 Properties available")
133134
print(f" Command API: {device.b01_q10_properties.command}")
134135
print(f" Vacuum Trait: {device.b01_q10_properties.vacuum}")
135-
136+
136137
except Exception as e:
137138
print(f"❌ Error checking device status: {e}")
138139
import traceback
140+
139141
traceback.print_exc()
140142

141143

@@ -152,11 +154,11 @@ async def interactive_menu(vacuum):
152154
print("6. Test all modes")
153155
print("0. Exit")
154156
print("=" * 50)
155-
157+
156158
while True:
157159
try:
158160
choice = input("\nEnter your choice (0-6): ").strip()
159-
161+
160162
if choice == "0":
161163
print("👋 Exiting...")
162164
break
@@ -196,15 +198,15 @@ async def main():
196198
try:
197199
user_params = await get_or_create_session()
198200
cache = FileCache(CACHE_PATH)
199-
201+
200202
print("\n🔄 Connecting to devices...")
201203
device_manager = await create_device_manager(user_params, cache=cache)
202204
devices = await device_manager.get_devices()
203-
205+
204206
print(f"\n📱 Found {len(devices)} device(s)")
205207
for idx, device in enumerate(devices, 1):
206208
print(f" {idx}. {device.name} ({device.product.model})")
207-
209+
208210
# Select device
209211
if len(devices) == 1:
210212
device = devices[0]
@@ -213,15 +215,15 @@ async def main():
213215
device_idx = int(input("\nSelect device number: ")) - 1
214216
device = devices[device_idx]
215217
print(f"\n✅ Selected device: {device.name}")
216-
218+
217219
# Check Q10 properties
218220
if device.b01_q10_properties is None:
219221
print("\n❌ This device doesn't have Q10 properties")
220222
await cache.flush()
221223
return
222-
224+
223225
vacuum = device.b01_q10_properties.vacuum
224-
226+
225227
# Show main menu
226228
print("\n" + "=" * 50)
227229
print("Q10 ADVANCED TEST SUITE")
@@ -233,11 +235,11 @@ async def main():
233235
print("5. Run all tests")
234236
print("0. Exit")
235237
print("=" * 50)
236-
238+
237239
while True:
238240
try:
239241
choice = input("\nSelect test (0-5): ").strip()
240-
242+
241243
if choice == "0":
242244
break
243245
elif choice == "1":
@@ -260,13 +262,15 @@ async def main():
260262
except Exception as e:
261263
print(f"❌ Error: {e}")
262264
import traceback
265+
263266
traceback.print_exc()
264-
267+
265268
await cache.flush()
266-
269+
267270
except Exception as e:
268271
print(f"\n❌ Fatal error: {e}")
269272
import traceback
273+
270274
traceback.print_exc()
271275

272276

0 commit comments

Comments
 (0)