Files
ai_ml_operations 8a97e3fbe2 Initial commit
2026-09-06 04:27:41 -07:00

43 lines
1.4 KiB
Python

from contacts.nominatim import normalize_hit
def test_line1_keeps_house_number_from_query_when_nominatim_omits_it():
raw = {
"display_name": (
"Greensboro Drive, Wheaton, DuPage County, Illinois, 60189, United States"
),
"address": {
"road": "Greensboro Drive",
"town": "Wheaton",
"county": "DuPage County",
"state": "Illinois",
"postcode": "60189",
"country_code": "us",
"ISO3166-2-lvl4": "US-IL",
},
}
hit = normalize_hit(raw, query="1968 Greensboro Drive, Wheaton")
assert hit["line1"] == "1968 Greensboro Drive"
assert hit["label"].startswith("1968 Greensboro Drive")
assert hit["city"] == "Wheaton"
assert hit["state"] == "IL"
assert hit["zip"] == "60189"
def test_line1_prefers_nominatim_house_number():
raw = {
"display_name": "1968 Greensboro Drive, Wheaton, Illinois, 60189, United States",
"address": {
"house_number": "1968",
"road": "Greensboro Drive",
"town": "Wheaton",
"state": "Illinois",
"postcode": "60189",
"country_code": "us",
"ISO3166-2-lvl4": "US-IL",
},
}
hit = normalize_hit(raw, query="1968 Greensboro Drive")
assert hit["line1"] == "1968 Greensboro Drive"
assert hit["label"] == raw["display_name"]