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>
This commit is contained in:
1 parent
4b42391a46
commit
57182188ba
30 files changed
+2846
-425
No files matched your search
@@ -1,7 +1,5 @@
|
||||
import pytest
|
||||
|
||||
from helpers import missing
|
||||
|
||||
# Test MACs from v1; no real driver has them
|
||||
ESPNOW_MAC = "aabbccddeeff"
|
||||
WIFI_MAC = "102030405060"
|
||||
@@ -33,12 +31,10 @@ def test_list(c):
|
||||
assert isinstance(resp.json(), dict)
|
||||
|
||||
|
||||
@missing("v1 device registry (MAC keys, validation)")
|
||||
def test_create_requires_name(c):
|
||||
assert c.post("/devices", json={}).status_code == 400
|
||||
|
||||
|
||||
@missing("v1 device registry (MAC keys, validation)")
|
||||
def test_create_espnow_keyed_by_mac(espnow_dev):
|
||||
dev = espnow_dev.json()
|
||||
assert list(dev) == [ESPNOW_MAC]
|
||||
@@ -50,7 +46,6 @@ def test_create_espnow_keyed_by_mac(espnow_dev):
|
||||
assert rec["address"] == ESPNOW_MAC
|
||||
|
||||
|
||||
@missing("v1 device registry (MAC keys, validation)")
|
||||
def test_get_espnow_has_no_connection_state(c, espnow_dev):
|
||||
resp = c.get(f"/devices/{ESPNOW_MAC}")
|
||||
assert resp.status_code == 200
|
||||
@@ -59,7 +54,6 @@ def test_get_espnow_has_no_connection_state(c, espnow_dev):
|
||||
assert c.get("/devices").json()[ESPNOW_MAC].get("connected") is None
|
||||
|
||||
|
||||
@missing("v1 device registry (MAC keys, validation)")
|
||||
def test_create_wifi(c, wifi_dev):
|
||||
rec = wifi_dev.json()[WIFI_MAC]
|
||||
assert rec["transport"] == "wifi"
|
||||
@@ -67,7 +61,6 @@ def test_create_wifi(c, wifi_dev):
|
||||
assert c.get(f"/devices/{WIFI_MAC}").json().get("connected") is False
|
||||
|
||||
|
||||
@missing("v1 device registry (MAC keys, validation)")
|
||||
def test_create_second_wifi_same_name(c, wifi_dev):
|
||||
resp = c.post("/devices", json={"name": "pytest-wifi", "transport": "wifi",
|
||||
"address": "192.168.50.11", "mac": WIFI_MAC2})
|
||||
@@ -76,30 +69,25 @@ def test_create_second_wifi_same_name(c, wifi_dev):
|
||||
assert c.delete(f"/devices/{WIFI_MAC2}").status_code == 200
|
||||
|
||||
|
||||
@missing("v1 device registry (MAC keys, validation)")
|
||||
def test_create_duplicate_mac(c, wifi_dev):
|
||||
resp = c.post("/devices", json={"name": "pytest-wifi-dupmac", "transport": "wifi",
|
||||
"address": "192.168.50.99", "mac": WIFI_MAC})
|
||||
assert resp.status_code == 409
|
||||
|
||||
|
||||
@missing("v1 device registry (MAC keys, validation)")
|
||||
def test_create_wifi_requires_mac(c):
|
||||
resp = c.post("/devices", json={"name": "no-mac-wifi", "transport": "wifi", "address": "192.168.50.12"})
|
||||
assert resp.status_code == 400
|
||||
|
||||
|
||||
@missing("v1 device registry (MAC keys, validation)")
|
||||
def test_create_rejects_unknown_transport(c):
|
||||
assert c.post("/devices", json={"name": "bad-tr", "transport": "serial"}).status_code == 400
|
||||
|
||||
|
||||
@missing("v1 device registry (MAC keys, validation)")
|
||||
def test_rename_blank(c, espnow_dev):
|
||||
assert c.put(f"/devices/{ESPNOW_MAC}", json={"name": " "}).status_code == 400
|
||||
|
||||
|
||||
@missing("v1 device registry (MAC keys, validation)")
|
||||
def test_rename(c, espnow_dev, wifi_dev):
|
||||
for mac in (ESPNOW_MAC, WIFI_MAC):
|
||||
resp = c.put(f"/devices/{mac}", json={"name": "renamed"})
|
||||
@@ -107,19 +95,16 @@ def test_rename(c, espnow_dev, wifi_dev):
|
||||
assert resp.json()["name"] == "renamed"
|
||||
|
||||
|
||||
@missing("v1 device registry (MAC keys, validation)")
|
||||
def test_cannot_change_mac(c, espnow_dev):
|
||||
assert c.put(f"/devices/{ESPNOW_MAC}", json={"mac": "001122334455"}).status_code == 400
|
||||
|
||||
|
||||
@missing("device identify")
|
||||
def test_identify(c, espnow_dev):
|
||||
resp = c.post(f"/devices/{ESPNOW_MAC}/identify")
|
||||
assert resp.status_code == 200
|
||||
assert resp.json().get("message")
|
||||
|
||||
|
||||
@missing("device identify")
|
||||
def test_identify_unknown(c):
|
||||
assert c.post("/devices/000000000000/identify").status_code == 404
|
||||
|
||||
@@ -130,7 +115,6 @@ def test_status(c):
|
||||
assert isinstance(resp.json(), dict)
|
||||
|
||||
|
||||
@missing("v1 device registry (MAC keys, validation)")
|
||||
def test_delete(c, espnow_dev):
|
||||
assert c.delete(f"/devices/{ESPNOW_MAC}").status_code == 200
|
||||
assert c.get(f"/devices/{ESPNOW_MAC}").status_code == 404
|
||||
Reference in new issue
Block a user