Files
led-controller/test/api/test_outputs.py
jimmyandClaude Opus 5.5 57182188ba feat: port the remaining v1 API to the v2 controller
Profiles seed presets, a default zone and a palette, and clone with their
own copies; deleting a profile removes what it owned. Zones get the v1
list shape, set-current, current, clone and content-fragment. Devices are
keyed by MAC with v1 validation and identify. Patterns: definitions, OTA
file and manifest, upload, driver, and send over ESP-NOW (the led-driver
pattern sources are embedded in the firmware). Pixel outputs get v1
validation and a DDP/Art-Net/sACN test pattern. Sequences, palettes and
settings follow v1 replies and validation, and /ws forwards browser
messages to the drivers.

The resource handlers move out of api.c into res_*.c, patterns.c and
outputs.c. cJSON now allocates from PSRAM: the store had grown enough to
starve internal RAM and abort the mic at boot. /status reports
free_internal.

The Wi-Fi AP and led-tool routes are left out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 09:58:17 +13:00

51 lines
1.5 KiB
Python

import pytest
@pytest.fixture
def output(c):
# 127.0.0.1 is the board itself, so the test frames go nowhere
resp = c.post("/outputs", json={"name": "pytest-wall", "protocol": "ddp", "host": "127.0.0.1",
"port": 9, "pixel_count": 10})
assert resp.status_code == 201, resp.text
oid = str(resp.json()["id"])
yield oid
c.delete(f"/outputs/{oid}")
def test_ddp_requires_host(c):
resp = c.post("/outputs", json={"name": "wall", "protocol": "ddp"})
assert resp.status_code == 400
assert "host" in resp.json()["error"]
def test_rejects_unknown_protocol(c):
assert c.post("/outputs", json={"name": "wall", "protocol": "hdmi", "host": "x"}).status_code == 400
def test_defaults(c, output):
rec = c.get(f"/outputs/{output}").json()
assert rec["color_order"] == "rgb"
assert rec["fps"] == 40
assert rec["enabled"] is True
def test_update(c, output):
resp = c.put(f"/outputs/{output}", json={"color_order": "grb"})
assert resp.status_code == 200
assert resp.json()["color_order"] == "grb"
def test_update_validates(c, output):
assert c.put(f"/outputs/{output}", json={"color_order": "xyz"}).status_code == 400
def test_test_pattern(c, output):
resp = c.post(f"/outputs/{output}/test", json={"step_s": 0.1})
assert resp.status_code == 200
assert resp.json()["status"]["frames"] > 0
def test_delete(c, output):
assert c.delete(f"/outputs/{output}").status_code == 200
assert c.get(f"/outputs/{output}").status_code == 404