Spaces:
Running
Running
Download backend/tests/test_url.py from HeshamXOR/MalwareGuard: direct link, hf CLI and curl.
- Browser
- Download file 627 Bytes
-
https://huggingface.co/spaces/HeshamXOR/MalwareGuard/resolve/main/backend/tests/test_url.py
- Command line
-
hf download hf://spaces/HeshamXOR/MalwareGuard/backend/tests/test_url.py
-
curl -L -o test_url.py https://huggingface.co/spaces/HeshamXOR/MalwareGuard/resolve/main/backend/tests/test_url.py
627 Bytes
| def test_url_analyze_happy_path(client): | |
| response = client.post( | |
| "/api/url/analyze", | |
| json={"url": "https://example.com/login", "threshold": 0.4}, | |
| ) | |
| assert response.status_code == 200 | |
| body = response.json() | |
| assert body["prediction"] == "Malicious" | |
| assert body["threshold_used"] == 0.4 | |
| def test_url_analyze_returns_503_when_model_not_loaded(client, services): | |
| services.url.model_loaded = False | |
| response = client.post("/api/url/analyze", json={"url": "https://example.com"}) | |
| assert response.status_code == 503 | |
| assert response.json()["detail"] == "URL model not loaded" | |