File size: 757 Bytes
1a73f90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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