Implement distribution management API and UI forms; add distribution model and tests
This commit is contained in:
33
tests/unit/test_distribution.py
Normal file
33
tests/unit/test_distribution.py
Normal file
@@ -0,0 +1,33 @@
|
||||
from fastapi.testclient import TestClient
|
||||
from main import app
|
||||
from config.database import Base, engine
|
||||
from models.distribution import Distribution
|
||||
|
||||
# Setup and teardown
|
||||
|
||||
|
||||
def setup_module(module):
|
||||
Base.metadata.create_all(bind=engine)
|
||||
|
||||
|
||||
def teardown_module(module):
|
||||
Base.metadata.drop_all(bind=engine)
|
||||
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
def test_create_and_list_distribution():
|
||||
# Create distribution
|
||||
payload = {"name": "NormalDist", "distribution_type": "normal",
|
||||
"parameters": {"mu": 0, "sigma": 1}}
|
||||
resp = client.post("/api/distributions/", json=payload)
|
||||
assert resp.status_code == 200
|
||||
data = resp.json()
|
||||
assert data["name"] == "NormalDist"
|
||||
|
||||
# List distributions
|
||||
resp2 = client.get("/api/distributions/")
|
||||
assert resp2.status_code == 200
|
||||
data2 = resp2.json()
|
||||
assert any(d["name"] == "NormalDist" for d in data2)
|
||||
Reference in New Issue
Block a user