42 lines
1.7 KiB
Python
42 lines
1.7 KiB
Python
"""计划预测支撑天数统一口径回归测试。"""
|
|
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
PRODUCTS_PY = (ROOT / "routes" / "products.py").read_text(encoding="utf-8")
|
|
PLANNING_PY = (ROOT / "routes" / "planning.py").read_text(encoding="utf-8")
|
|
|
|
|
|
class PlanningSupportDaysConsistencyTest(unittest.TestCase):
|
|
def test_detail_reuses_the_list_and_export_enrichment(self):
|
|
detail_source = PRODUCTS_PY.split("def product_planning_detail():", 1)[1].split(
|
|
"@products_bp.route('/api/bom/list')", 1
|
|
)[0]
|
|
self.assertIn("from routes.planning import _enrich_row_with_planning_data", detail_source)
|
|
self.assertIn("row = _enrich_row_with_planning_data(", detail_source)
|
|
self.assertNotIn("total_inv = prod_transit + inv15_val", detail_source)
|
|
|
|
def test_cloud_and_external_detail_use_shared_support_days(self):
|
|
detail_source = PRODUCTS_PY.split("def product_planning_detail():", 1)[1].split(
|
|
"@products_bp.route('/api/bom/list')", 1
|
|
)[0]
|
|
self.assertIn("'总支撑天数': row.get('云仓支撑天数', 999)", detail_source)
|
|
self.assertIn("'总支撑天数': row.get('外仓支撑天数', 999)", detail_source)
|
|
|
|
def test_export_accepts_real_support_day_field_names(self):
|
|
export_source = PLANNING_PY.split("def planning_export():", 1)[1].split(
|
|
"def planning_page():", 1
|
|
)[0]
|
|
for field in (
|
|
"库存工厂可支撑天数",
|
|
"加工厂库存支撑天数",
|
|
"库存工厂待生产可支撑天数",
|
|
):
|
|
self.assertIn(field, export_source)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|