Skip to content

Commit 7f1ea92

Browse files
author
github-actions
committed
test: add advanced international address cases
1 parent d9251c3 commit 7f1ea92

1 file changed

Lines changed: 106 additions & 0 deletions

File tree

tests/test_address_parser.py

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,3 +979,109 @@ def test_parse_auto_fallback_on_us_validation_error() -> None:
979979
assert result.source == "international"
980980
assert result.is_valid
981981
assert result.international_address is not None
982+
983+
984+
# Extended international/US complex cases for libpostal
985+
ADVANCED_COMPLEX_ADDRESSES = [
986+
# United States / Territories
987+
(
988+
"Sales Dept, Building C, 4th Floor, Suite 450, 1234 W. 56th St., "
989+
"Los Angeles, CA 90037-1234, USA"
990+
),
991+
"Corner of 5th Ave & W 34th St, Manhattan, New York, NY 10001, USA",
992+
"RR 2 Box 152, PO Box 45, Springfield, KY 40069, USA",
993+
"789 north main street apartment 5b chicago il 60614 usa",
994+
"PSC 808 Box 33, APO AE 09618-0033, USA",
995+
"Urb. Jardines de Caparra, Calle 3 B-15, Bayamón, PR 00959-1234, USA",
996+
# Canada
997+
"Unit 507-1234 Rue Sainte-Catherine Ouest, Montréal QC H3B 1E5, Canada",
998+
"Site 2 Comp 12 RR 1, 24567 Highway 16 E, Vegreville AB T9C 1C2, Canada",
999+
# UK / Ireland
1000+
"Flat 5B, Wellington House, 123-125 High Holborn, Camden, London WC1V 6EA, United Kingdom",
1001+
"Rose Cottage, Church Lane, Little Wittenham, Oxfordshire OX14 4QG, United Kingdom",
1002+
"Apartment 3, Block B, Smithfield Village, Smithfield, Dublin 7, D07 FXY2, Ireland",
1003+
# Western Europe
1004+
"Musterstraße 45, Hinterhaus, 3. OG rechts, 10999 Berlin, Deutschland",
1005+
(
1006+
"c/o M. Jean Dupont, 18 Rue de la République, Bâtiment B, Escalier 2, 3ème étage, "
1007+
"13002 Marseille CEDEX 01, France"
1008+
),
1009+
"Calle de Alcalá, 123, Bloque 4, Esc. B, 5º Dcha, 28009 Madrid, España",
1010+
"c/o Studio Legale Rossi, Via Garibaldi 21, Scala A, Int. 7, 16124 Genova GE, Italia",
1011+
"Keizersgracht 123B-III, 1015 CJ Amsterdam, Nederland",
1012+
"Bahnhofstrasse 7, App. 12, 8001 Zürich ZH, Schweiz",
1013+
"Karl Johans gate 15, 2. etg, NO-0159 Oslo, Norge",
1014+
# Eastern Europe / Russia / Turkey / Greece
1015+
"ул. Арбат, д. 12, корп. 3, стр. 5, кв. 18, Москва, 119019, Россия",
1016+
"ul. Jana Pawła II 45/12, 00-175 Warszawa, Polska",
1017+
"Λεωφόρος Βασιλίσσης Σοφίας 10, 4ος όροφος, 106 74 Αθήνα, Ελλάδα",
1018+
"Atatürk Mahallesi, Gül Sokak No:25 Daire:8, 34758 Ümraniye/İstanbul, Türkiye",
1019+
# Middle East / Israel
1020+
"רחוב הרצל 15, דירה 7, שכונת נווה צדק, תל אביב-יפו 6511101, ישראל",
1021+
"Office 804, Tower A, Business Bay, PO Box 123456, Dubai, United Arab Emirates",
1022+
# South Asia
1023+
(
1024+
"Flat 802, Tower 5, Brigade Gateway, beside Orion Mall, Dr. Rajkumar Road, "
1025+
"Malleswaram West, Bengaluru 560055, Karnataka, India"
1026+
),
1027+
(
1028+
"H.No. 3-45, Near Hanuman Temple, Malkajgiri Village, Medchal-Malkajgiri Dist., "
1029+
"Telangana 500047, India"
1030+
),
1031+
"House #27-B, Mohallah Gulshan-e-Rehman, Tehsil Samundri, District Faisalabad 37300, Pakistan",
1032+
(
1033+
"Holding 12/B, Road 3, Block A, Bashundhara R/A, Badda Thana, Dhaka 1229, "
1034+
"Dhaka Division, Bangladesh"
1035+
),
1036+
# East Asia
1037+
"〒160-0022 東京都新宿区新宿3丁目38-1 ルミネエスト新宿 7階",
1038+
"Lumine Est Shinjuku 7F, 3-38-1 Shinjuku, Shinjuku-ku, Tokyo 160-0022, Japan",
1039+
"中国江苏省苏州市工业园区独墅湖高教区仁爱路199号 创新创业大厦A座1508室 215123",
1040+
(
1041+
"Room 1508, Building A, Chuangxin Chuangye Dasha, 199 Ren'ai Rd, "
1042+
"Dushu Lake Sci-Edu Innovation District, Suzhou, Jiangsu 215123, China"
1043+
),
1044+
"서울특별시 마포구 양화로 45, 10층 1001호 (서교동), 04038, 대한민국",
1045+
"Flat A, 23/F, Tower 3, Laguna City, 8 Laguna Street, Lam Tin, Kowloon, Hong Kong",
1046+
"Blk 123 Ang Mo Kio Ave 3 #12-345, Singapore 560123",
1047+
# Southeast Asia & Oceania
1048+
(
1049+
"Unit 4B, Building 2, Eastwood Citywalk, 188 E. Rodriguez Jr. Ave., "
1050+
"Brgy. Bagumbayan, Quezon City 1110, Metro Manila, Philippines"
1051+
),
1052+
"Jl. Sudirman No. 25 RT 04/RW 06, Kel. Menteng, Kec. Menteng, Jakarta Pusat 10310, Indonesia",
1053+
"Lot 7, 255 Old Northern Rd, Castle Hill NSW 2154, Australia",
1054+
"103 Smiths Road, RD 2, Hamilton 3282, New Zealand",
1055+
# Africa & Latin America
1056+
"12B 7th Avenue, Parktown North, Johannesburg, Gauteng 2193, South Africa",
1057+
(
1058+
"Flat 6, Block C, Lekki Gardens Estate, Km 15 Lekki-Epe Expressway, Ajah, "
1059+
"Eti-Osa LGA, Lagos State, Nigeria"
1060+
),
1061+
(
1062+
"Av. Insurgentes Sur 1602, Piso 9, Colonia Crédito Constructor, "
1063+
"Alcaldía Benito Juárez, 03940 Ciudad de México, CDMX, México"
1064+
),
1065+
"Rua do Catete, 311, Bloco B, Apto 1203, Flamengo, Rio de Janeiro - RJ, 22220-001, Brasil",
1066+
"Av. Corrientes 1234, Piso 7º, Depto. C, C1043AAX Ciudad Autónoma de Buenos Aires, Argentina",
1067+
"Los Militares 5001, Oficina 1204, Las Condes, Región Metropolitana, 7550000, Chile",
1068+
# Messy / unstructured
1069+
"attn billing john smith 4th flr 99 king street east toronto on m5c1g4 canada",
1070+
' "The Old Mill" , 7\tMill Road .. Ballymena BT42 1AA UK ',
1071+
"fl 3 rm 305, 18 yonge st, tornto on m5e 1z8 canada",
1072+
"Station Road, near City Center Mall, Sector 17, Chandigarh 160017, Mohali, Punjab, India",
1073+
(
1074+
"Starbucks Coffee inside Central Station, Main Concourse, 89 E 42nd St, Midtown, "
1075+
"Manhattan, New York, NY 10017-5503, USA"
1076+
),
1077+
]
1078+
1079+
1080+
@pytest.mark.parametrize("addr", ADVANCED_COMPLEX_ADDRESSES)
1081+
def test_parse_auto_advanced_complex_addresses(addr: str) -> None:
1082+
_require_libpostal()
1083+
service = AddressService()
1084+
result = service.parse_auto_route(addr, validate=True)
1085+
assert result.source in {"us", "international"}
1086+
assert result.error is None
1087+
assert result.address is not None or result.international_address is not None

0 commit comments

Comments
 (0)