28 lines
838 B
Python
28 lines
838 B
Python
from services.reporting import generate_report
|
|
from routes.reporting import router
|
|
from fastapi.testclient import TestClient
|
|
from main import app
|
|
import pytest
|
|
|
|
# Function test
|
|
def test_generate_report_empty():
|
|
report = generate_report([])
|
|
assert isinstance(report, dict)
|
|
|
|
# Endpoint test
|
|
def test_reporting_endpoint_invalid_input():
|
|
client = TestClient(app)
|
|
resp = client.post("/api/reporting/summary", json={})
|
|
assert resp.status_code == 400
|
|
assert resp.json()["detail"] == "Invalid input format"
|
|
|
|
|
|
def test_reporting_endpoint_success():
|
|
client = TestClient(app)
|
|
# Minimal input: list of dicts
|
|
input_data = [{"iteration": 1, "result": 10.0}]
|
|
resp = client.post("/api/reporting/summary", json=input_data)
|
|
assert resp.status_code == 200
|
|
data = resp.json()
|
|
assert isinstance(data, dict)
|