File size: 1,077 Bytes
4bc3460
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""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