Add comprehensive test suite with mocked hardware#24
Merged
Conversation
Add tests for Controller, Motor, ContinuousMotor, Rotator, Linear, Iris, Slider, Shutter, and scan modules using mocked serial ports. No hardware required — all tests run in CI. https://claude.ai/code/session_01P9qVe3TkpdEfGtupr8TxC4
The `if instruction == b"ho"` branch was unreachable since the command dict already maps home_clockwise to b"ho0" and home_anticlockwise to b"ho1". This was a leftover from an earlier design. Removing it brings coverage to 100%. https://claude.ai/code/session_01P9qVe3TkpdEfGtupr8TxC4
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Remove unused imports (logging, pytest, patch, PropertyMock) and unused local variables (status) flagged by ruff. https://claude.ai/code/session_01P9qVe3TkpdEfGtupr8TxC4
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
This PR adds a comprehensive test suite for the elliptec library using mocked serial ports and controllers, eliminating the need for physical hardware during testing. The test suite covers all device classes (Rotator, Linear, Iris, Slider, Shutter) and core components (Controller, scan module).
Key Changes
New Test Files
tests/test_devices_mock.py: Comprehensive tests for all device classes using mocked controllers
tests/test_controller.py: Controller class tests with mocked serial ports
tests/test_scan.py: Scan module tests
tests/conftest.py: Shared test fixtures and utilities
make_info_response(): Factory function for creating canned info responsesmock_controllerfixture: Pre-configured mocked Controller instanceTest Infrastructure
unittest.mockfor mocking serial ports and controller responses_make_device()instantiates device classes with mocked controllersExisting Code Updates
Implementation Details
https://claude.ai/code/session_01P9qVe3TkpdEfGtupr8TxC4