Add unit tests for CiA 402 profile (coverage 36% → 45%)#644
Open
bizfsc wants to merge 1 commit intocanopen-python:masterfrom
Open
Add unit tests for CiA 402 profile (coverage 36% → 45%)#644bizfsc wants to merge 1 commit intocanopen-python:masterfrom
bizfsc wants to merge 1 commit intocanopen-python:masterfrom
Conversation
Add 24 unit tests covering: - State402 enum and state decoding from statusword - Command word generation for state transitions - Next-state calculation through the state machine - Homing status evaluation - Operation mode switching and reading - TPDO callback handling for statusword updates - Lookup table consistency checks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add 24 unit tests for
canopen/profiles/p402.pyto improve test coverage from 36% to 45%.Tests Added
State402.decode_statusword()for all defined statesIS_HOMING/HOMING_COMPLETED/HOMING_ERRORevaluationApproach
Uses a minimal
ObjectDictionarywith the required DS402 objects (0x6040 controlword, 0x6041 statusword, 0x6060/0x6061 operation mode, 0x6502 supported drives). PDO maps are mocked withunittest.mock.MagicMockto test the TPDO callback path without requiring a real CAN bus.Coverage
The remaining uncovered code is primarily in
BaseNode402methods that require a live CAN bus interaction (SDO reads/writes, NMT state changes, PDO communication).