33 lines
1.0 KiB
Python
33 lines
1.0 KiB
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("ZNB16754796") == "16754796"
|
|
assert normalize_po_number("ZNB-16754796") == "16754796"
|
|
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"
|