X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/4774e45218bcfcef3390f820ad48b1b67b2bd0c4..baf1b955fb27e9b4e4c7c1146b87627e13be6ac1:/test/python/tokenizer/sanitizers/test_clean_housenumbers.py diff --git a/test/python/tokenizer/sanitizers/test_clean_housenumbers.py b/test/python/tokenizer/sanitizers/test_clean_housenumbers.py index 5784619b..34cc7413 100644 --- a/test/python/tokenizer/sanitizers/test_clean_housenumbers.py +++ b/test/python/tokenizer/sanitizers/test_clean_housenumbers.py @@ -42,3 +42,27 @@ def test_housenumber_lists(sanitize, number): def test_filter_kind(sanitize): assert sanitize(housenumber='34', number='4', badnumber='65') == \ [('badnumber', '65'), ('housenumber', '34'), ('housenumber', '4')] + + +@pytest.mark.parametrize('number', ('6523', 'n/a', '4')) +def test_convert_to_name_converted(number): + sanitizer_args = {'step': 'clean-housenumbers', + 'convert-to-name': (r'\d+', 'n/a')} + + place = PlaceInfo({'address': {'housenumber': number}}) + names, address = PlaceSanitizer([sanitizer_args]).process_names(place) + + assert ('housenumber', number) in set((p.kind, p.name) for p in names) + assert 'housenumber' not in set(p.kind for p in address) + + +@pytest.mark.parametrize('number', ('a54', 'n.a', 'bow')) +def test_convert_to_name_unconverted(number): + sanitizer_args = {'step': 'clean-housenumbers', + 'convert-to-name': (r'\d+', 'n/a')} + + place = PlaceInfo({'address': {'housenumber': number}}) + names, address = PlaceSanitizer([sanitizer_args]).process_names(place) + + assert 'housenumber' not in set(p.kind for p in names) + assert ('housenumber', number) in set((p.kind, p.name) for p in address)