Skip to content

Add Q10 VacuumTrait Test Scripts - #758

Open
lboue wants to merge 3 commits into
Python-roborock:mainfrom
lboue:test-q10-vacuum-trait
Open

Add Q10 VacuumTrait Test Scripts#758
lboue wants to merge 3 commits into
Python-roborock:mainfrom
lboue:test-q10-vacuum-trait

Conversation

@lboue

@lbouelboue commented Feb 1, 2026

Copy link
Copy Markdown
Contributor

Add Q10 VacuumTrait Test Scripts

This PR adds test scripts to verify the Q10 VacuumTrait functionality introduced in PR #754.

What's Added

Two test scripts in Q10:

  1. test_q10_simple.py - Comprehensive test script with detailed debugging

    • Shows all available device properties and APIs
    • Verbose output for troubleshooting
    • Validates vacuum trait presence
  2. test_q10_vacuum.py - Streamlined test script for daily use

    • Quick device detection and selection
    • Clean, minimal output
    • Interactive menu for testing commands
  3. README.md - Complete documentation with:

    • Installation and setup instructions
    • Usage examples
    • Available commands reference
    • Troubleshooting guide

Features

Both scripts provide an interactive menu to test all

- Add test_q10_simple.py: Interactive test script with detailed debug info
- Add test_q10_vacuum.py: Basic test script for Q10 vacuum commands
- Add test_q10_advanced.py: Advanced test suite with complex features
- Add confirmation prompt for map creation mode to prevent accidents
- Update README.md with comprehensive usage guide and troubleshooting
@lboue
lboueforce-pushed the test-q10-vacuum-trait branch from 3283fbb to aaac719CompareFebruary 1, 2026 07:21
- Rename test_q10_*.py to run_q10_*.py to prevent pytest from treating them as unit tests
- These are interactive scripts, not automated tests
- Update README with new script names
- Fixes pytest failures in CI
@lbouelboue mentioned this pull request Feb 1, 2026
@lboue
lboue marked this pull request as ready for review February 1, 2026 07:49
CopilotAI review requested due to automatic review settings February 1, 2026 07:49

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds three example/test scripts and comprehensive documentation for testing the Q10 VacuumTrait functionality introduced in PR #754. The scripts provide different levels of testing and diagnostics for Q10 vacuum devices.

Changes:

  • Added three test scripts with varying levels of detail: run_q10_vacuum.py (basic), run_q10_simple.py (detailed debug), and run_q10_advanced.py (comprehensive testing suite)
  • Added comprehensive README.md with installation instructions, usage examples, command reference, and troubleshooting guide
  • All scripts include authentication flow, device selection, and interactive menus for testing vacuum commands

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 13 comments.

FileDescription
examples/Q10/run_q10_vacuum.pyBasic test script with minimal output for quick testing of Q10 vacuum commands
examples/Q10/run_q10_simple.pyDetailed test script with comprehensive device diagnostics and verbose output
examples/Q10/run_q10_advanced.pyAdvanced test suite with multiple cleaning modes, device status monitoring, and structured test categories
examples/Q10/README.mdComplete documentation including installation, usage instructions, command reference, and troubleshooting guide

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

continue

print(f"\n • {mode_name}")
await vacuum._command.send(

CopilotAIFeb 1, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is accessing the private attribute vacuum._command directly. This breaks encapsulation and could cause issues if the internal implementation of VacuumTrait changes. Consider adding a public method in the VacuumTrait class for sending custom commands with parameters, or use the existing public methods to avoid accessing private attributes.

Suggested change
awaitvacuum._command.send(
awaitvacuum.send_command(

Copilot uses AI. Check for mistakes.
Comment on lines +75 to +76
device_idx = int(input("\nSelect device number: ")) - 1
device = devices[device_idx]

CopilotAIFeb 1, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The device selection input on line 75 lacks error handling for invalid inputs. If the user enters a non-numeric value or an out-of-range number, the script will crash with an exception. Consider adding a try-except block or input validation to handle ValueError (for non-numeric input) and IndexError (for out-of-range values) more gracefully.

Suggested change
device_idx=int(input("\nSelect device number: ")) -1
device=devices[device_idx]
whileTrue:
selection=input("\nSelect device number: ")
try:
device_idx=int(selection) -1
exceptValueError:
print("❌ Invalid input. Please enter a number corresponding to a device.")
continue
if0<=device_idx<len(devices):
device=devices[device_idx]
break
else:
print(f"❌ Invalid selection. Please enter a number between 1 and {len(devices)}.")

Copilot uses AI. Check for mistakes.
Comment on lines +125 to +131
await cache.flush()

except Exception as e:
print(f"\n❌ Fatal error: {e}")
import traceback

traceback.print_exc()

CopilotAIFeb 1, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If an exception occurs before line 125, the cache may not be flushed, potentially losing cached data. Consider using a try-finally block or ensuring cache.flush() is called in both the success and exception paths to guarantee the cache is properly flushed even when errors occur.

Copilot uses AI. Check for mistakes.
Comment on lines +153 to +159
await cache.flush()

except Exception as e:
print(f"\n❌ Fatal error: {e}")
import traceback

traceback.print_exc()

CopilotAIFeb 1, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If an exception occurs before line 153, the cache may not be flushed, potentially losing cached data. Consider using a try-finally block or ensuring cache.flush() is called in both the success and exception paths to guarantee the cache is properly flushed even when errors occur.

Suggested change
awaitcache.flush()
exceptExceptionase:
print(f"\n❌ Fatal error: {e}")
importtraceback
traceback.print_exc()
exceptExceptionase:
print(f"\n❌ Fatal error: {e}")
importtraceback
traceback.print_exc()
finally:
cache_obj=locals().get("cache")
ifcache_objisnotNone:
awaitcache_obj.flush()

Copilot uses AI. Check for mistakes.
print(f"\n❌ Fatal error: {e}")
import traceback

traceback.print_exc()

CopilotAIFeb 1, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If an exception occurs before line 268, the cache may not be flushed, potentially losing cached data. Consider using a try-finally block or ensuring cache.flush() is called in both the success and exception paths to guarantee the cache is properly flushed even when errors occur.

Suggested change
traceback.print_exc()
traceback.print_exc()
# Ensure the cache is flushed even when a fatal error occurs
if"cache"inlocals():
try:
awaitcache.flush()
exceptException:
# Suppress cache flush errors to avoid masking the original exception
pass

Copilot uses AI. Check for mistakes.
Comment on lines +64 to +67
device_idx = int(input("\nSelect device number: ")) - 1
device = devices[device_idx]
print(f"\n✅ Selected device: {device.name}")

CopilotAIFeb 1, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The device selection input on line 64 lacks error handling for invalid inputs. If the user enters a non-numeric value or an out-of-range number, the script will crash with an exception. Consider adding a try-except block or input validation to handle ValueError (for non-numeric input) and IndexError (for out-of-range values) more gracefully.

Suggested change
device_idx=int(input("\nSelect device number: ")) -1
device=devices[device_idx]
print(f"\n✅ Selected device: {device.name}")
whileTrue:
selection=input("\nSelect device number: ").strip()
try:
device_idx=int(selection) -1
exceptValueError:
print("❌ Invalid input. Please enter a number corresponding to a device.")
continue
if0<=device_idx<len(devices):
device=devices[device_idx]
print(f"\n✅ Selected device: {device.name}")
break
else:
print(f"❌ Invalid device number. Please enter a number between 1 and {len(devices)}.")

Copilot uses AI. Check for mistakes.
Comment on lines +215 to +216
device_idx = int(input("\nSelect device number: ")) - 1
device = devices[device_idx]

CopilotAIFeb 1, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The device selection input on line 215 lacks error handling for invalid inputs. If the user enters a non-numeric value or an out-of-range number, the script will crash with an exception. Consider adding a try-except block or input validation to handle ValueError (for non-numeric input) and IndexError (for out-of-range values) more gracefully.

Suggested change
device_idx=int(input("\nSelect device number: ")) -1
device=devices[device_idx]
whileTrue:
selection=input(f"\nSelect device number (1-{len(devices)}): ").strip()
try:
device_idx=int(selection) -1
device=devices[device_idx]
break
exceptValueError:
print("❌ Please enter a valid number.")
exceptIndexError:
print(f"❌ Please enter a number between 1 and {len(devices)}.")

Copilot uses AI. Check for mistakes.
Comment on lines +59 to +66
# Select device
if len(devices) == 1:
device = devices[0]
print(f"\n✅ Using device: {device.name}")
else:
device_idx = int(input("\nSelect device number: ")) - 1
device = devices[device_idx]
print(f"\n✅ Selected device: {device.name}")

CopilotAIFeb 1, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The device selection logic doesn't handle the case where no devices are found (len(devices) == 0). If no devices are available, the else branch will be taken, prompting for input and then attempting to access an empty list, which will cause an IndexError. Consider adding a check for empty device list before the selection logic and returning early with an appropriate error message.

Copilot uses AI. Check for mistakes.
Comment on lines +210 to +217
# Select device
if len(devices) == 1:
device = devices[0]
print(f"\n✅ Using device: {device.name}")
else:
device_idx = int(input("\nSelect device number: ")) - 1
device = devices[device_idx]
print(f"\n✅ Selected device: {device.name}")

CopilotAIFeb 1, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The device selection logic doesn't handle the case where no devices are found (len(devices) == 0). If no devices are available, the else branch will be taken, prompting for input and then attempting to access an empty list, which will cause an IndexError. Consider adding a check for empty device list before the selection logic and returning early with an appropriate error message.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,135 @@
#!/usr/bin/env python3

CopilotAIFeb 1, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description mentions "test_q10_simple.py" and "test_q10_vacuum.py" but the actual files are named "run_q10_simple.py" and "run_q10_vacuum.py". This creates confusion between the PR description and actual file names. Consider either updating the PR description or renaming the files to maintain consistency.

Copilot uses AI. Check for mistakes.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@lboue