Add production safety controls

This commit is contained in:
2026-06-18 13:24:17 +02:00
parent 01e5464ec1
commit 3c6fe24b03
11 changed files with 316 additions and 13 deletions

View File

@@ -19,7 +19,7 @@ def test_health_and_backup_roundtrip(tmp_path, monkeypatch) -> None: # type: ig
restore = client.post("/v2/backup/restore", json=backup.json())
assert health.status_code == 200
assert health.json()["version"] == "2.0.0-alpha.8"
assert health.json()["version"] == "2.0.0-alpha.9"
assert backup.status_code == 200
assert restore.status_code == 200
assert restore.json() == {"status": "restored"}
@@ -66,6 +66,17 @@ def test_dashboard_control_and_learning_endpoints(tmp_path, monkeypatch) -> None
"confidence": 0.91,
},
)
simulation = client.post(
"/v2/simulate",
json={
"actuator_entity_id": "light.storage",
"trigger_entity_id": "binary_sensor.storage_door",
"trigger_state": "on",
},
)
readiness = client.get("/v2/control/light.storage/readiness")
global_control = client.post("/v2/control/global", json={"enabled": False})
detailed_health = client.get("/v2/health")
dashboard = client.get("/v2/dashboard")
assert entities.status_code == 200
@@ -77,5 +88,13 @@ def test_dashboard_control_and_learning_endpoints(tmp_path, monkeypatch) -> None
assert control.json()["stage"] == "dry_run"
assert learning.status_code == 200
assert learning.json()["patterns"][0]["trigger_entity_id"] == "binary_sensor.storage_door"
assert simulation.status_code == 200
assert simulation.json()["decision"]["target_state"] == "on"
assert readiness.status_code == 200
assert readiness.json()["ready"] is False
assert global_control.status_code == 200
assert global_control.json()["global_enabled"] is False
assert detailed_health.status_code == 200
assert detailed_health.json()["global_enabled"] is False
assert dashboard.status_code == 200
assert dashboard.json()["actuator_count"] == 1