test: port the v1 endpoint and browser tests to v2

HTTP tests against a running controller (make test-api HOST=ip). They
snapshot every collection through /db and restore it afterwards. v1
behaviour v2 does not have yet is marked as a strict xfail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jimmyandClaude Opus 5.5 committed 2026-11-03 01:33:08 +13:00
1 parent 9d628aa3c8
commit 4b42391a46
15 files changed
+2055 -1

No files matched your search

+55
View File
@@ -0,0 +1,55 @@
import pytest
from helpers import missing
# Every test here fails on v2
pytestmark = missing("pixel outputs (DDP, Art-Net, sACN, DMX)")
@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