Files
led-controller/test/api/README.md
T
jimmyandClaude Opus 5.5 bfeeb958df feat: main's import/export, zones, audio API and web UI
Profiles, presets and sequences export and import as main's bundles.
Zones carry group_ids, preset_group_ids, sequence_ids, content_kind and
brightness; profiles seed rainbow as colour_cycle, and deleting a
profile also deletes its sequences. Groups, zones and sequences written
by older versions are migrated at boot.

/api/audio (status, event stream, start/stop, reset, anchor-bar,
devices) maps main's audio detector onto the mic's beat detector. Audio
start/stop picks whether mic beats or the BPM clock time sequences; the
clock's beats also go to the drivers while the mic is off.
/ws now greets from a post-handshake callback (httpd does not call the
handler for the upgrade).

The web UI is main's, plus v2's outputs editor, list search and
hostname/static IP settings; the bridge, Wi-Fi AP and led-tool parts
are gone. API tests follow main's behaviour (119 pass on the board).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 20:34:22 +13:00

28 lines
1.7 KiB
Markdown

# API tests
HTTP tests against a running controller, ported from the Python app's endpoint tests (`tests/test_endpoints_pytest.py` and `tests/test_endpoints.py`) on both the `animation-engine` and `main` lines, plus `main`'s bundle, audio, group and sequence tests where they work over HTTP. They need `pytest`, `requests` and `websocket-client`.
```bash
make test-api HOST=10.1.1.180
```
or `python3 -m pytest test/api --host <ip>` (or set `LED_HOST`). Without a host every test is skipped.
The tests create and delete profiles, presets, zones and so on. The sequence tests switch mic timing off and run the beat clock at 200 BPM for a few seconds; mic timing is switched back on afterwards. Before the run they save every collection (`GET /db/<name>`), and afterwards they write each one back (`PUT /db/<name>`). Zone play and preset send do go out over ESP-NOW. They use made-up driver names (`pytest-a`, `pytest-nobody`) so real drivers ignore them.
## v1 features v2 does not have yet
A test for v1 behaviour that v2 is missing is marked `@missing("<feature>")`. That is a strict `xfail`, so the test shows as `x`, and it fails as `XPASS(strict)` once the feature works. When that happens, remove the marker. To list what is still missing:
```bash
python3 -m pytest test/api --host <ip> -rx
```
v1 tests that were not ported:
- the model and engine unit tests (`tests/models/`, `tests/engine_tests/`), which test Python modules that have no C counterpart;
- the Wi-Fi/TCP/UDP driver test servers.
The checks on exact driver messages became checks on status codes and replies, because ESP-NOW frames can't be captured from outside the board.
The Selenium UI tests are in `test/browser/` (`make test-browser HOST=<ip>`).