feat(bot-bridge): 新增会计科目写入端点 POST /api/cma/bot/subjects — 行级全量校验+按subject_code幂等UPSERT(dry_run/update_existing开关)+L3留痕, 绝不DELETE (dama-cma-subjects-write-endpoint-20260912)

This commit is contained in:
Hermes CI Fix
2026-09-12 10:42:46 +08:00
parent af541e9043
commit 840d98765d
4 changed files with 400 additions and 6 deletions
+4 -3
View File
@@ -49,12 +49,12 @@ class TestRiskMapCoverage:
assert not unlabeled, f"以下路由函数缺少 @risk_level 装饰器: {unlabeled}"
def test_risk_level_counts(self):
"""分级统计与方案一致:L1=21(20项清单+risk-levels端点)、L2=6(4项清单+okr/create+bot建议通道)、L3=4(+字典写入)、L4=0"""
"""分级统计与方案一致:L1=21(20项清单+risk-levels端点)、L2=6(4项清单+okr/create+bot建议通道)、L3=5(+字典写入+科目写入)、L4=0"""
from collections import Counter
counts = Counter(API_RISK_MAP.values())
assert counts["L1"] == 21, counts
assert counts["L2"] == 6, counts
assert counts["L3"] == 4, counts
assert counts["L3"] == 5, counts
assert counts["L4"] == 0, "Bot API面不得存在L4端点(安全底线)"
def test_no_l4_bot_endpoints(self):
@@ -92,11 +92,12 @@ class TestRiskLevelsEndpoint:
assert apis["POST /api/cma/bot/import"]["risk_level"] == "L3"
assert apis["POST /api/cma/bot/import"]["handling"] # 处理方式非空
assert apis["POST /api/cma/bot/dict/zxt-account"]["risk_level"] == "L3"
assert apis["POST /api/cma/bot/subjects"]["risk_level"] == "L3"
# 分级统计
assert data["summary"]["L1"] == 21
assert data["summary"]["L2"] == 6
assert data["summary"]["L3"] == 4
assert data["summary"]["L3"] == 5
assert data["summary"]["L4"] == 0