Skip to content

Refactor/test prod split - #17

Merged
frozenwizard merged 2 commits into
mainfrom
refactor/test-prod-split
Aug 3, 2026
Merged

Refactor/test prod split#17
frozenwizard merged 2 commits into
mainfrom
refactor/test-prod-split

Conversation

@frozenwizard

Copy link
Copy Markdown
Owner

This refactors more of the local test and production spslit.

frozenwizard and others added 2 commits August 2, 2026 21:45
- 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>
@frozenwizard
frozenwizard merged commit 56c298c into main Aug 3, 2026
5 checks passed
@frozenwizard
frozenwizard deleted the refactor/test-prod-split branch August 3, 2026 03:18
Sign up for free to 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.

1 participant