64dc85bd14
- inventory业务层下沉(薄路由+service orchestration模式): - customer/supplier/warehouse -> master_data_service - material_routes(价格历史/趋势/供应商关联)-> material_service - product_routes(CRUD/BOM/from-task跨模块桥接)-> product_service - dashboard_routes(首页统计/低库存预警)-> dashboard_service - inventory侧新增service回归覆盖(dashboard 2 / master_data 10 / material 10 / product 14),含跨模块桥接测试种子 - Pydantic v2弃用清零:全仓14处 class Config 全部迁移到 model_config = ConfigDict(from_attributes=True)(含 shared auth) - datetime.utcnow() 弃用清零:auth_service 3处统一改 datetime.now(timezone.utc) - 同步文档:STATUS / ROADMAP / TECH_DEBT(D12清偿)/ AGENTS 代码地图 测试基线:126 passed, 4 skipped(无deprecation warning) Co-Authored-By: Claude Code <noreply@anthropic.com>
40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
import pytest
|
|
|
|
|
|
@pytest.mark.anyio
|
|
async def test_dashboard_returns_seeded_summary(client):
|
|
resp = await client.get("/api/dashboard")
|
|
assert resp.status_code == 200
|
|
body = resp.json()
|
|
assert body["material_count"] == 1
|
|
assert body["finished_product_count"] == 2
|
|
assert body["supplier_count"] == 1
|
|
assert body["customer_count"] == 1
|
|
assert body["warehouse_count"] == 1
|
|
assert body["total_stock"] == 1000
|
|
assert float(body["total_value"]) == 10000.0
|
|
assert body["pending_purchase"] == 0
|
|
assert body["pending_sales"] == 0
|
|
assert body["low_stock_products"] == []
|
|
|
|
|
|
@pytest.mark.anyio
|
|
async def test_dashboard_low_stock_products_are_listed(client):
|
|
inventory = await client.get("/api/inventory")
|
|
assert inventory.status_code == 200
|
|
inv_id = next(row["id"] for row in inventory.json()["items"] if row["product_sku"] == "MAT-001")
|
|
|
|
updated = await client.put(
|
|
f"/api/inventory/{inv_id}",
|
|
json={"quantity": 0, "locked_quantity": 0},
|
|
)
|
|
assert updated.status_code == 200
|
|
|
|
resp = await client.get("/api/dashboard")
|
|
assert resp.status_code == 200
|
|
low_stock = resp.json()["low_stock_products"]
|
|
assert len(low_stock) == 1
|
|
assert low_stock[0]["sku"] == "MAT-001"
|
|
assert low_stock[0]["quantity"] == 0
|
|
assert low_stock[0]["min_stock"] == 0
|