Refactor and enhance CalMiner application
- Updated README.md to reflect new features and usage instructions. - Removed deprecated Dashboard.html component and integrated dashboard functionality directly into the main application. - Revised architecture documentation for clarity and added module map and request flow diagrams. - Enhanced maintenance model to include equipment association and cost tracking. - Updated requirements.txt to include new dependencies (httpx, pandas, numpy). - Improved consumption, maintenance, production, and reporting routes with better validation and response handling. - Added unit tests for maintenance and production routes, ensuring proper CRUD operations and validation. - Enhanced reporting service to calculate and return detailed summary statistics. - Redesigned Dashboard.html for improved user experience and integrated Chart.js for visualizing simulation results.
This commit is contained in:
@@ -3,14 +3,19 @@ from main import app
|
||||
from config.database import Base, engine
|
||||
|
||||
# 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_production_output():
|
||||
# Create a scenario to attach production output
|
||||
resp = client.post(
|
||||
@@ -21,9 +26,10 @@ def test_create_and_list_production_output():
|
||||
sid = scenario["id"]
|
||||
|
||||
# Create Production Output item
|
||||
prod_payload = {"scenario_id": sid, "amount": 300.0, "description": "Daily output"}
|
||||
prod_payload = {"scenario_id": sid,
|
||||
"amount": 300.0, "description": "Daily output"}
|
||||
resp2 = client.post("/api/production/", json=prod_payload)
|
||||
assert resp2.status_code == 200
|
||||
assert resp2.status_code == 201
|
||||
prod = resp2.json()
|
||||
assert prod["scenario_id"] == sid
|
||||
assert prod["amount"] == 300.0
|
||||
@@ -32,4 +38,5 @@ def test_create_and_list_production_output():
|
||||
resp3 = client.get("/api/production/")
|
||||
assert resp3.status_code == 200
|
||||
data = resp3.json()
|
||||
assert any(item["amount"] == 300.0 and item["scenario_id"] == sid for item in data)
|
||||
assert any(item["amount"] == 300.0 and item["scenario_id"]
|
||||
== sid for item in data)
|
||||
|
||||
Reference in New Issue
Block a user