feat(family): deploy Single-Writer DuckDB backend, Mila parent cockpit & feeding analytics, and Moritz macro tracker
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
|
||||
def test_generic_query_select(client: TestClient):
|
||||
payload = {
|
||||
"query": "SELECT count(*) AS cnt FROM v_sleep WHERE subject = 'mila'"
|
||||
}
|
||||
resp = client.post("/duckdb-api/v1/query", json=payload)
|
||||
assert resp.status_code == 200
|
||||
data = resp.json()
|
||||
assert "rows" in data
|
||||
assert len(data["rows"]) == 1
|
||||
assert data["rows"][0]["cnt"] > 0
|
||||
assert data["execution_time_ms"] < 50.0 # verifies sub-50ms execution
|
||||
|
||||
|
||||
def test_generic_query_disallowed_drop(client: TestClient):
|
||||
payload = {"query": "DROP TABLE sleep;"}
|
||||
resp = client.post("/duckdb-api/v1/query", json=payload)
|
||||
assert resp.status_code == 400
|
||||
assert "not permitted" in resp.json()["detail"]
|
||||
|
||||
|
||||
def test_generic_query_disallowed_insert(client: TestClient):
|
||||
payload = {"query": "INSERT INTO sleep VALUES ('x', 'y')"}
|
||||
resp = client.post("/duckdb-api/v1/query", json=payload)
|
||||
assert resp.status_code == 400
|
||||
Reference in New Issue
Block a user