Add unit tests for scenarios, parameters, reporting, and simulation features
This commit is contained in:
27
tests/unit/test_reporting.py
Normal file
27
tests/unit/test_reporting.py
Normal file
@@ -0,0 +1,27 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user