refactor(vendor): 抽出缺貨 API 查詢服務
All checks were successful
CD Pipeline / deploy (push) Successful in 2m11s

This commit is contained in:
OoO
2026-05-01 14:12:56 +08:00
parent b5de8d5d61
commit fbc85fcedc
8 changed files with 157 additions and 131 deletions

View File

@@ -255,6 +255,23 @@ def test_vendor_stockout_list_v2_is_production_default_and_uses_real_stockout_ro
assert "" not in template
def test_vendor_stockout_api_queries_are_extracted_to_service():
route_source = (ROOT / "routes/vendor_routes.py").read_text(encoding="utf-8")
service_source = (ROOT / "services/vendor_stockout_query_service.py").read_text(encoding="utf-8")
api_section = route_source.split("def api_get_stockout_list():", 1)[1].split("@vendor_bp.route('/api/stockout/<int:stockout_id>'", 1)[0]
assert "get_stockout_api_list_payload(" in api_section
assert "get_stockout_batches_payload(vendor_db)" in api_section
assert "session.query(VendorStockout)" not in api_section
assert "def get_stockout_api_list_payload(" in service_source
assert "def get_stockout_batches_payload(vendor_db)" in service_source
assert "'batch_number': record.batch_id" in service_source
assert "'send_status': record.status or 'pending'" in service_source
assert "'latest_date': batch.latest_date.isoformat()" in service_source
assert "from flask" not in service_source
def test_vendor_stockout_import_v2_is_feature_flagged_and_does_not_ship_sample_rows():
route_source = (ROOT / "routes/vendor_routes.py").read_text(encoding="utf-8")
template = (ROOT / "templates/vendor_stockout_import_v2.html").read_text(encoding="utf-8")