]> git.openstreetmap.org Git - nominatim.git/blobdiff - test/python/tokenizer/sanitizers/test_clean_postcodes.py
add type annotations for indexer
[nominatim.git] / test / python / tokenizer / sanitizers / test_clean_postcodes.py
index 228c2f3a1a9adf3331c4536ce03468a875f96426..237527f1e44c7064cf8be6e2c3025353a1774ebd 100644 (file)
@@ -10,8 +10,8 @@ Tests for the sanitizer that normalizes postcodes.
 import pytest
 
 from nominatim.tokenizer.place_sanitizer import PlaceSanitizer
-from nominatim.indexer.place_info import PlaceInfo
-from nominatim.tools import country_info
+from nominatim.data.place_info import PlaceInfo
+from nominatim.data import country_info
 
 @pytest.fixture
 def sanitize(def_config, request):
@@ -88,3 +88,15 @@ def test_postcode_sweden_pass(sanitize, postcode):
 def test_postcode_sweden_fail(sanitize, postcode):
     assert sanitize(country='se', postcode=postcode) == []
 
+
+@pytest.mark.parametrize("postcode", ('AB1', '123-456-7890', '1 as 44'))
+@pytest.mark.sanitizer_params(default_pattern='[A-Z0-9- ]{3,12}')
+def test_postcode_default_pattern_pass(sanitize, postcode):
+    assert sanitize(country='an', postcode=postcode) == [('postcode', postcode.upper())]
+
+
+@pytest.mark.parametrize("postcode", ('C', '12', 'ABC123DEF 456', '1234,5678', '11223;11224'))
+@pytest.mark.sanitizer_params(convert_to_address=False, default_pattern='[A-Z0-9- ]{3,12}')
+def test_postcode_default_pattern_fail(sanitize, postcode):
+    assert sanitize(country='an', postcode=postcode) == []
+