File size: 489 Bytes
6d20eab | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | from fastapi.testclient import TestClient
from app.main import app
client = TestClient(app)
def test_history():
response = client.get("/api/v1/history")
assert response.status_code == 200
data = response.json()
# The endpoint returns a list of risk points, not an object with an
# "incidents" key
assert isinstance(data, list)
if data: # if not empty, verify the structure of the first item
assert "risk" in data[0]
assert "time" in data[0]
|