本次提交新增货代订单处理全流程的完整业务能力、数据库迁移与测试用例: 1. 统一追加式审计事件体系,支持全链路不可篡改的业务追溯 2. 货代任务撤销、版本替代管控逻辑,规范已上传订单的合规版本更替 3. 订单抽取路由审计、模板自动冻结资格、路由计数等核心业务基建 4. EML订单补充表解析契约与合并逻辑,完善订单补全能力 5. Chatflow只读能力令牌校验机制,保障工具调用安全 6. 人工复核证据校验服务,规范人工审核的证据留存 所有变更均配套完整的单元测试与迁移契约测试,支持受控回退
43 lines
1.4 KiB
Python
43 lines
1.4 KiB
Python
from app.services.shipping_notice.po_number import (
|
|
find_po_number_in_document,
|
|
normalize_atomic_po_number,
|
|
normalize_po_number,
|
|
)
|
|
from app.services.shipping_notice.extract import extract_notice_fields
|
|
|
|
|
|
def test_find_po_number_in_document():
|
|
text = """
|
|
PO Number: PO-2026-001
|
|
PR Number: ADU_S-PO260528126265@1000140351
|
|
"""
|
|
assert find_po_number_in_document(text) == "PO-2026-001"
|
|
|
|
|
|
def test_po_number_not_from_pr_number():
|
|
text = "PR Number: ADU_S-PO260528126265@1000140351"
|
|
assert find_po_number_in_document(text) == ""
|
|
|
|
|
|
def test_normalize_po_number():
|
|
assert normalize_po_number(" PO-99 ") == "PO-99"
|
|
assert normalize_po_number("ZNB16754796") == "16754796"
|
|
assert normalize_po_number("ZNB-16754796") == "16754796"
|
|
assert normalize_po_number("") == ""
|
|
|
|
|
|
def test_normalize_atomic_po_number_rejects_multi_value_text():
|
|
"""多个 PO 的邮件摘要不能充当跨文档合并的单一订单身份。"""
|
|
assert normalize_atomic_po_number('4518738152 & 4518838154') == ''
|
|
assert normalize_atomic_po_number('ZNB-16754796') == '16754796'
|
|
|
|
|
|
def test_extract_notice_fields_includes_po_number():
|
|
structured = {
|
|
"po_number": "PO-2026-001",
|
|
"lines": [{"sku": "A-001", "qty": 1}],
|
|
"confidence": 0.9,
|
|
}
|
|
parsed, _, _ = extract_notice_fields(raw_text="", structured=structured)
|
|
assert parsed["po_number"] == "PO-2026-001"
|