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"