from fastapi.testclient import TestClient from led_platform.main import app def test_bootstrap_returns_tile_scene_and_timing_data(): client = TestClient(app) response = client.get("/api/bootstrap/left") assert response.status_code == 200 data = response.json() assert data["tile"]["id"] == "left" assert data["state"]["active_view"] assert data["server_time_ms"] > 0 def test_switch_scene_returns_scheduled_commit_payload(): client = TestClient(app) response = client.post("/api/scenes/energy/switch") assert response.status_code == 200 data = response.json() assert data["state"]["active_scene_id"] == "energy" assert data["state"]["active_view"] == "energy" assert data["apply_at_ms"] > data["server_time_ms"] def test_action_rejects_unsupported_action(): client = TestClient(app) response = client.post("/api/actions", json={"action": "eval.anything"}) assert response.status_code == 400 def test_sync_status_endpoint_exposes_commands_and_nodes(): client = TestClient(app) response = client.get("/api/sync/status") assert response.status_code == 200 data = response.json() assert "nodes" in data assert "commands" in data