feat: 本体字段治理与风险规则模板执行器重构
- 新增本体字段注册表与字段治理审计脚本 - 重构风险规则模板执行器、DSL 验证与清单分类器 - 完善票据夹服务与差旅请求详情页交互 - 优化趋势图表与总览页数据展示 - 增强报销平台风险分级与模拟公司筛选 - 补充本体字段、风险规则生成与票据夹服务测试覆盖
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from app.api.deps import CurrentUserContext
|
||||
from app.core.config import get_settings
|
||||
from app.schemas.ocr import OcrRecognizeDocumentRead
|
||||
@@ -67,3 +69,41 @@ def test_receipt_folder_train_ticket_uses_invoice_date_and_enriches_fields(monke
|
||||
assert fields["列车出发时间"] == "2026-02-20 08:30"
|
||||
finally:
|
||||
get_settings.cache_clear()
|
||||
|
||||
|
||||
def test_receipt_folder_delete_receipts_for_claim_removes_linked_receipts(monkeypatch, tmp_path) -> None:
|
||||
monkeypatch.setenv("STORAGE_ROOT_DIR", str(tmp_path / "storage"))
|
||||
get_settings.cache_clear()
|
||||
try:
|
||||
current_user = CurrentUserContext(
|
||||
username="pytest",
|
||||
name="Py Test",
|
||||
role_codes=[],
|
||||
is_admin=False,
|
||||
)
|
||||
service = ReceiptFolderService()
|
||||
receipt = service.save_receipt(
|
||||
filename="linked-receipt.pdf",
|
||||
content=b"%PDF-1.4 linked",
|
||||
media_type="application/pdf",
|
||||
current_user=current_user,
|
||||
linked_claim_id="claim-1",
|
||||
linked_claim_no="RE-001",
|
||||
linked_item_id="item-1",
|
||||
document=OcrRecognizeDocumentRead(
|
||||
filename="linked-receipt.pdf",
|
||||
media_type="application/pdf",
|
||||
text="invoice number 123 amount 100",
|
||||
document_type="vat_invoice",
|
||||
document_type_label="invoice",
|
||||
scene_code="other",
|
||||
scene_label="receipt",
|
||||
),
|
||||
)
|
||||
|
||||
assert service.get_receipt(receipt.id, current_user).linked_claim_id == "claim-1"
|
||||
assert service.delete_receipts_for_claim("claim-1") == 1
|
||||
with pytest.raises(FileNotFoundError):
|
||||
service.get_receipt(receipt.id, current_user)
|
||||
finally:
|
||||
get_settings.cache_clear()
|
||||
|
||||
Reference in New Issue
Block a user