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:
@@ -3,6 +3,7 @@ import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlalchemy.orm import Session
|
||||
from tests.conftest import create_test_user, get_token_for_user, auth_header, create_test_kpi
|
||||
from datetime import datetime
|
||||
from app.models.budget_plan import BudgetPlan
|
||||
from app.models import KPIValue, SystemConfig, CashPlan
|
||||
|
||||
@@ -341,14 +342,21 @@ class TestBudgetRollForward:
|
||||
data = resp.json()
|
||||
assert "滚动预算已延展" in data["message"]
|
||||
assert len(data["rolled_kpis"]) == 1
|
||||
# 新增月份 = 当前月(08) + 12 = 明年08
|
||||
assert data["rolled_kpis"][0]["added_period"].startswith("2027-")
|
||||
# 新增月份 = 当前月 + rolling_months(12)(实现口径见 budget.py:budget_roll_forward)
|
||||
# 用例原写死 2026-08+12=2027-08,跨月后与实现错配(2026-09 跨月实证)
|
||||
now = datetime.now()
|
||||
exp_year, exp_month = now.year, now.month + 12
|
||||
while exp_month > 12:
|
||||
exp_month -= 12
|
||||
exp_year += 1
|
||||
expected_period = f"{exp_year}-{exp_month:02d}"
|
||||
assert data["rolled_kpis"][0]["added_period"] == expected_period
|
||||
|
||||
# 最早月(2026-01)被删除
|
||||
from app.models import BudgetPlan as BP
|
||||
periods = [p.period for p in db.query(BP).filter(BP.kpi_id == kpi.id).all()]
|
||||
assert "2026-01" not in periods
|
||||
assert "2027-08" in periods
|
||||
assert expected_period in periods
|
||||
|
||||
|
||||
class TestBudgetComparison:
|
||||
|
||||
Reference in New Issue
Block a user