Spaces:
Running
Running
Download backend/tests/test_predict.py from HeshamXOR/MalwareGuard: direct link, hf CLI and curl.
- Browser
- Download file 757 Bytes
-
https://huggingface.co/spaces/HeshamXOR/MalwareGuard/resolve/main/backend/tests/test_predict.py
- Command line
-
hf download hf://spaces/HeshamXOR/MalwareGuard/backend/tests/test_predict.py
-
curl -L -o test_predict.py https://huggingface.co/spaces/HeshamXOR/MalwareGuard/resolve/main/backend/tests/test_predict.py
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 | |