deltamind.hf.space / tests /test_api.py
Emeritus-21's picture
Upload 2 files
4bc3460 verified
Raw
History Blame Contribute Delete
1.08 kB
"""Basic API tests for DeltaMind."""
import pytest
from fastapi.testclient import TestClient
from app.main import app
client = TestClient(app)
def test_health():
r = client.get("/api/health")
assert r.status_code == 200
assert r.json()["status"] == "ok"
def test_dashboard():
r = client.get("/api/dashboard")
assert r.status_code == 200
d = r.json()
assert "stats" in d
assert "flares" in d
def test_anomaly():
r = client.post("/api/ai/anomaly", json={"oil_rate":500,"pressure":2000,"water_cut":85,"temperature":145})
assert r.status_code == 200
assert "is_anomaly" in r.json()
def test_predict():
r = client.post("/api/ai/predict", json={"id":"EQ-001","type":"ESP","vibration":0.3,"temperature":70,"runtime_hours":4000,"pressure":150})
assert r.status_code == 200
assert "failure_probability" in r.json()
def test_flares():
r = client.get("/api/flares")
assert r.status_code == 200
def test_weather():
r = client.get("/api/weather")
assert r.status_code == 200