Add animation frame integrity tests #58

Merged
JackFrostbyte merged 2 commits from test/issue-49-animation-frame-integrity-tests into develop 2026-05-15 18:05:55 -04:00
Collaborator

Summary

  • Adds tests/test_animation_registry.py covering every registered animation in rgb_aura.animation_registry.enabled_zone_animations().
  • Tests are parametrized over the registry, so adding a new animation automatically gets integrity coverage with no test changes required.
  • All tests run against the zone shapes declared in config/device_map.json, so the suite mirrors real runtime conditions without OpenRGB hardware.
  • Total runtime ~50 ms.

Coverage

Registry-level invariants (3 tests)

  • Registry has at least one enabled animation.
  • All animation_name values are unique within the registry.
  • No registered animation targets the reserved zone (reserved_argb_6_led_zone).

Per-animation invariants (parametrized, ×14 animations)

  • Required attributes — every animation declares animation_name, logical_zone_name, and a callable builder.
  • Builder produces at least one frame — no animation is silently empty.
  • Frame color count matches zone LED count — mirrors the runtime invariant in runtime._build_runtime_zones. Any drift between animation shape and declared zone shape fails here.
  • Frame durations are positive — no zero or negative durations sneak through.
  • Colors are valid RGB integers in 0–255 — guarded by RgbColor.__post_init__ at construction, but asserted explicitly so any future refactor that bypasses RgbColor (e.g. plain tuples) fails fast.
  • Non-usable LED positions stay at DARK_BLUE — for zones with usable_led_indexes smaller than expected_zone_led_count, all non-usable positions in every frame must equal DARK_BLUE. Skipped where all LEDs are usable (nothing to constrain).

Result on the current registry

  • 77 tests pass, 11 skipped.
  • All 11 skips are the "outside usable indexes" check on zones whose full LED range is usable (GPU, top fractal fans, thermaltake aurora fans). On these zones the constraint is vacuous.
  • The motherboard zone (3 LEDs total, 2 usable) exercises the strict DARK_BLUE check on its non-usable 3rd LED across all 3 motherboard animations — all pass.

Verification

  • python -m pytest tests/ — 77 passed, 11 skipped.
  • ruff format src tests scripts — 30 files already formatted.
  • ruff check src tests scripts — all checks passed.
  • python -m rgb_aura.main --dry-run --dry-run-events 3 — clean run, all 14 animations registered, scheduler preview produces events normally.

Hardware verification

Not required. Tests call animation builders directly with declared zone shapes; no real SDK, no hardware, no LED write path touched.

Linked issue

Closes #49.

Branch workflow

  • Base branch: develop
  • Work branch: test/issue-49-animation-frame-integrity-tests
  • Pull request target: develop
  • Not merged directly into main.

Notes for reviewer

  • This PR is independent of PR #57 (device mapping tests). It does not depend on the tests/conftest.py helpers added there — the animation registry tests are self-contained.
  • The "non-usable indexes stay at DARK_BLUE" assertion encodes the current convention seen in animation builders (colors = [DARK_BLUE for _ in range(zone_led_count)] followed by selective writes). If a future animation wants to express a different intent for non-usable LEDs, that decision should be made explicitly with an issue rather than by silently breaking this test.
## Summary - Adds `tests/test_animation_registry.py` covering every registered animation in `rgb_aura.animation_registry.enabled_zone_animations()`. - Tests are parametrized over the registry, so adding a new animation automatically gets integrity coverage with no test changes required. - All tests run against the zone shapes declared in `config/device_map.json`, so the suite mirrors real runtime conditions without OpenRGB hardware. - Total runtime ~50 ms. ## Coverage ### Registry-level invariants (3 tests) - Registry has at least one enabled animation. - All `animation_name` values are unique within the registry. - No registered animation targets the reserved zone (`reserved_argb_6_led_zone`). ### Per-animation invariants (parametrized, ×14 animations) - **Required attributes** — every animation declares `animation_name`, `logical_zone_name`, and a callable `builder`. - **Builder produces at least one frame** — no animation is silently empty. - **Frame color count matches zone LED count** — mirrors the runtime invariant in `runtime._build_runtime_zones`. Any drift between animation shape and declared zone shape fails here. - **Frame durations are positive** — no zero or negative durations sneak through. - **Colors are valid RGB integers in 0–255** — guarded by `RgbColor.__post_init__` at construction, but asserted explicitly so any future refactor that bypasses `RgbColor` (e.g. plain tuples) fails fast. - **Non-usable LED positions stay at `DARK_BLUE`** — for zones with `usable_led_indexes` smaller than `expected_zone_led_count`, all non-usable positions in every frame must equal `DARK_BLUE`. Skipped where all LEDs are usable (nothing to constrain). ## Result on the current registry - 77 tests pass, 11 skipped. - All 11 skips are the "outside usable indexes" check on zones whose full LED range is usable (GPU, top fractal fans, thermaltake aurora fans). On these zones the constraint is vacuous. - The motherboard zone (3 LEDs total, 2 usable) exercises the strict `DARK_BLUE` check on its non-usable 3rd LED across all 3 motherboard animations — all pass. ## Verification - [x] `python -m pytest tests/` — 77 passed, 11 skipped. - [x] `ruff format src tests scripts` — 30 files already formatted. - [x] `ruff check src tests scripts` — all checks passed. - [x] `python -m rgb_aura.main --dry-run --dry-run-events 3` — clean run, all 14 animations registered, scheduler preview produces events normally. ## Hardware verification Not required. Tests call animation builders directly with declared zone shapes; no real SDK, no hardware, no LED write path touched. ## Linked issue Closes #49. ## Branch workflow - Base branch: `develop` - Work branch: `test/issue-49-animation-frame-integrity-tests` - Pull request target: `develop` - Not merged directly into `main`. ## Notes for reviewer - This PR is independent of PR #57 (device mapping tests). It does not depend on the `tests/conftest.py` helpers added there — the animation registry tests are self-contained. - The "non-usable indexes stay at `DARK_BLUE`" assertion encodes the current convention seen in animation builders (`colors = [DARK_BLUE for _ in range(zone_led_count)]` followed by selective writes). If a future animation wants to express a different intent for non-usable LEDs, that decision should be made explicitly with an issue rather than by silently breaking this test.
JackFrostbyte deleted branch test/issue-49-animation-frame-integrity-tests 2026-05-15 18:05:55 -04:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
JackFrostbyte/rgb-aura!58
No description provided.