petter2025's picture
Upload folder using huggingface_hub (#3)
6d20eab
raw
history blame contribute delete
978 Bytes
from fastapi.testclient import TestClient
from app.main import app
client = TestClient(app)
def test_get_risk():
"""Endpoint returns 501 with a deprecation message."""
response = client.get(
"/api/v1/get_risk",
headers={
"X-API-Key": "test-key"})
assert response.status_code == 501
data = response.json()
assert "deprecated" in data.get("detail", "").lower()
def test_get_risk_internal_error(client, monkeypatch):
"""Force an internal error – the endpoint should return 500."""
import app.api.routes_risk
def mock_get_system_risk():
raise ValueError("test error")
monkeypatch.setattr(
app.api.routes_risk,
"get_system_risk",
mock_get_system_risk)
response = client.get(
"/api/v1/get_risk",
headers={
"X-API-Key": "test-key"})
assert response.status_code == 500
data = response.json()
assert "test error" in data.get("detail", "")