Refactor/test prod split - #17
Merged
Merged
Conversation
- LEDEffects now takes the hardware at construction; PWM effects use the injected instance instead of calling the global get_hardware() factory. BaseGundam exposes self.effects so lightshows stay hardware-agnostic - run_server(settings, hardware) in webserver.py is the single composition point shared by main.py and tests/LocalServerTest.py; host/port/debug come from settings with on-device defaults, and the local server runs on unprivileged port 8080 - get_hardware() imports its implementation lazily, so the Pico never loads mock code and the laptop never touches machine/network - Mocks (MockPin, MockPWM, MockLED, NoOpNetworking) move to module level in VirtualHardware.py; MockLED leaves the production LED module - BoardLED accepts an injected pin, so VirtualHardware reuses the real class with a MockPin instead of a hand-copied MockBoardLED, and VirtualHardware caches board_led/networking to match PicoHardware - New pytest suite (tests/test_virtual_hardware.py, 9 tests) exercises the seam on VirtualHardware, with a CI workflow to run it; repo-root conftest.py makes src importable under pytest - developer_setup.md headless examples updated to the current API Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- LEDEffects: brighten delegates to brighten_all; the ramp now lands exactly on end_percent (range() stops short), and a try/finally guarantees pwm.deinit() plus hardware.reset_pin() so a cancelled show can't leave a cached LED pin stuck on the PWM mux. - reset_pin now takes the Pin object itself; on the Pico, machine.Pin accepts an existing Pin as the id and re-muxes it in place. - Replace cancel_lightshow/current_task attribute tracking with a LightshowManager that owns the task and serializes start/stop with a lock, closing the race where overlapping requests orphaned a show. A show that died on its own no longer fails the cancelling request. - Document optional host/port/debug keys in config.py.template, drop the mutable default in get_all_leds, make src/test.py's machine import lazy. - Tests updated for LightshowManager, plus a regression test for the overlapping-start race. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
This refactors more of the local test and production spslit.