test: CMA自动化测试补覆盖 226→452用例, 覆盖率36%→60%
- 新增8个测试文件(bot_bridge/kpi_causality/cash/predict/reports/tax_compliance/expenses/probe_cost) - 增强 budget/auth/users + conftest账套模式适配 - 测试驱动修复: bot_bridge导入batch_id→source_batch; cash_forecast extra空dict - 全量: 451 passed, 1 xfailed; 报告 docs/cma-test-coverage-report.md
This commit is contained in:
@@ -529,7 +529,7 @@ def bot_import_excel(
|
||||
continue
|
||||
|
||||
kv = KPIValue(kpi_id=kpi.id, period=period, actual_value=val,
|
||||
batch_id=hashlib.md5(f"{datetime.now()}".encode()).hexdigest()[:12])
|
||||
source_batch=hashlib.md5(f"{datetime.now()}".encode()).hexdigest()[:12])
|
||||
db.add(kv)
|
||||
count += 1
|
||||
except Exception as e:
|
||||
|
||||
@@ -320,6 +320,7 @@ def calculate_accuracy(entity_id: int, db: Session) -> list:
|
||||
|
||||
def generate_scenario_suggestion(alert_type: str, kpi_name: str, extra: dict = None) -> dict:
|
||||
"""根据预警类型生成情景建议"""
|
||||
extra = extra or {}
|
||||
suggestions = {
|
||||
"cash_low": {
|
||||
"title": "现金流紧张缓解方案",
|
||||
@@ -624,7 +625,7 @@ def forecast_cash_flow_with_plans(
|
||||
def check_cash_alerts(db: Session, entity_id: int = 1) -> dict:
|
||||
"""资金预警 — 缺口前3天预警 + 到期未收款提醒,写入预警中心(kpi_alerts)"""
|
||||
import json as _json
|
||||
from app.models import KPIAlert, CashPlan
|
||||
from app.models import KPIAlert, CashPlan, KPIDefinition
|
||||
|
||||
result = forecast_cash_flow_with_plans(entity_id, db, days=30)
|
||||
new_alerts = []
|
||||
|
||||
Reference in New Issue
Block a user