feat: Allow RoborockModeEnum parsing by either enum name, value name, or code.#711
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enhances the RoborockModeEnum class with flexible parsing capabilities by adding from_name() and from_value() methods that support case-insensitive lookups. This complements the existing from_code() method and will be used for command line parsing for Q10 commands. The PR also introduces the first test file in the tests/data directory to validate these new parsing methods.
Key Changes:
- Added case-insensitive
from_value()andfrom_name()methods toRoborockModeEnum - Created test suite for the new enum parsing methods using the
B01_Q10_DPenum
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
roborock/data/code_mappings.py |
Added from_value() and from_name() class methods to RoborockModeEnum for flexible, case-insensitive enum member lookup |
tests/data/test_code_mappings.py |
New test file validating the three parsing methods (from_code, from_name, from_value) with various case combinations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… or code This will be used for command line parsing for Q10 commands. Adds the first tests in the tests/data directory since we moved many containers here.
b7b45cf to
520ae1e
Compare
Lash-L
left a comment
There was a problem hiding this comment.
technically we can have duplicate strings. but that is a pretty big edge case.
In general - we should look up via code when possible.
This will be used for command line parsing for Q10 commands. Adds the first tests in the tests/data directory since we moved many containers here.
Pulled out of #709