test(cma): clear 10 pre-existing baseline failures (cma-baseline-tests-cleanup-20260915)
No production code changed. Root causes were all test-side staleness: - test_cash TestVoucherImport: fixture filename contained 'test' -> rejected by the intentional import guard (d71c7fe); renamed, and missing-columns case now asserts the column check is what returns 400 - test_budget_tech_improve TestP1ValueCollect: seeded voucher_details source rows; collector deliberately skips empty aggregates sinced71c7fe(no more implicit 0), and preview call now passes an explicit period - test_roadmap_r2r5 / test_budget / test_ai_suggestions: seeds hardcoded 2026-08 (authoring month) while detectors/rule engine use the current month -> replaced with current-period seeds pytest tests/ -q -rf: 1094 passed, 1 xfailed, 0 failed (baseline was 10 failed, 1084 passed, 1 xfailed)
This commit is contained in:
@@ -231,9 +231,12 @@ class TestRuleSuggestions:
|
||||
create_test_user(db)
|
||||
token = get_token_for_user(client)
|
||||
kpi = create_test_kpi(db, target_value=100.0)
|
||||
db.add(KPIValue(kpi_id=kpi.id, period="2026-08", actual_value=200.0))
|
||||
db.add(BudgetPlan(entity_id=1, kpi_id=kpi.id, period="2026-08", budget_value=100.0,
|
||||
budget_year=2026, budget_month=8, status="active"))
|
||||
# 规则引擎按「当月」取预算(ai_analysis.py: _generate_rule_suggestions 的 period)
|
||||
# 原用例写死 2026-08(编写时的当月),跨月后与实现错配 → 恒 0 条(2026-09 跨月实证)
|
||||
period = datetime.now().strftime("%Y-%m")
|
||||
db.add(KPIValue(kpi_id=kpi.id, period=period, actual_value=200.0))
|
||||
db.add(BudgetPlan(entity_id=1, kpi_id=kpi.id, period=period, budget_value=100.0,
|
||||
budget_year=int(period[:4]), budget_month=int(period[5:7]), status="active"))
|
||||
db.commit()
|
||||
|
||||
resp = client.get("/api/cma/ai/dashboard-analysis", headers=auth_header(token))
|
||||
|
||||
Reference in New Issue
Block a user