Skip to content

Commit c16fca6

Browse files
authored
Add test for predict endpoint in test_predict.py
1 parent 3116663 commit c16fca6

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

backend/tests/test_predict.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from fastapi.testclient import TestClient
2+
from backend.main import app
3+
4+
client = TestClient(app)
5+
6+
def test_predict_endpoint():
7+
payload = {
8+
"source_ip": "10.0.0.1",
9+
"destination_ip": "10.0.0.2",
10+
"bytes_sent": 1000,
11+
"bytes_received": 2000,
12+
"protocol": "TCP",
13+
"failed_login_count": 0
14+
}
15+
resp = client.post("/predict/", json=payload)
16+
assert resp.status_code == 200
17+
body = resp.json()
18+
for key in ("score", "label", "confidence"):
19+
assert key in body

0 commit comments

Comments
 (0)