MalwareGuard / backend /tests /test_predict.py
HeshamXOR's picture
Deploy MalwareGuard FastAPI backend clean
1a73f90 verified
Raw History Blame Contribute Delete
757 Bytes
def test_predict_happy_path(client, features, sha256):
response = client.post("/api/predict", json={"features": features, "sha256": sha256})
assert response.status_code == 200
body = response.json()
assert body["prediction"]["prediction"] == "Malicious"
assert body["prediction"]["probability"] == 0.91
assert body["prediction"]["sha256"] == sha256
def test_predict_rejects_wrong_feature_count(client):
response = client.post("/api/predict", json={"features": [0.0] * 10})
assert response.status_code == 422
def test_predict_rejects_bad_threshold(client, features):
response = client.post(
"/api/predict",
json={"features": features, "threshold": 1.5},
)
assert response.status_code == 422