mirror of
https://github.com/Sea-Haven-Industries/procurement-ingest.git
synced 2026-09-30 09:33:15 +00:00
30 lines
865 B
Python
30 lines
865 B
Python
|
|
"""Tests for pad_zip in the PO email processor."""
|
||
|
|
|
||
|
|
import pytest
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.mark.parametrize(
|
||
|
|
("raw", "expected"),
|
||
|
|
[
|
||
|
|
# Missing values pass through untouched
|
||
|
|
(None, None),
|
||
|
|
("", ""),
|
||
|
|
# Leading zeros restored (Coupa drops them: "MA 2149" -> "02149")
|
||
|
|
("2149", "02149"),
|
||
|
|
("7001", "07001"),
|
||
|
|
("501", "00501"),
|
||
|
|
# Already-valid 5-digit zips are unchanged
|
||
|
|
("85704", "85704"),
|
||
|
|
("02149", "02149"),
|
||
|
|
# Zip+4: leading zeros restored on the base, suffix preserved
|
||
|
|
("2149-1234", "02149-1234"),
|
||
|
|
("85704-1234", "85704-1234"),
|
||
|
|
# Surrounding whitespace is handled
|
||
|
|
(" 2149 ", "02149"),
|
||
|
|
# Non-numeric values are left alone
|
||
|
|
("ABC12", "ABC12"),
|
||
|
|
],
|
||
|
|
)
|
||
|
|
def test_pad_zip(po_handler, raw, expected):
|
||
|
|
assert po_handler.pad_zip(raw) == expected
|