Files
syops/backend/tests/test_shipping_notice_po_number.py
T
hugo 8deae3146b feat(shipping-notice): 完成货代发货通知全流程开发与代码重构
- 新增PO号提取、预约ID解析(支持`PR@xxx`格式)工具,完善库存匹配逻辑
- 新增库存映射缓存、匹配/解析结果格式化摘要,优化用户提示
- 修复数据库迁移脚本未检查表存在的问题,避免全新部署失败
- 新增路径工具类统一管理相对路径,优化配置文件处理逻辑
- 归档旧文档,将部署、Dify配置合并到`shipping_notice.md`
- 新增完整单元测试与集成测试覆盖核心流程
- 更新前端国际化与会话管理逻辑,优化界面交互
2026-06-04 15:26:34 +08:00

31 lines
951 B
Python

from app.services.shipping_notice.po_number import find_po_number_in_document, 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("") == ""
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"