From: Sarah Hoffmann Date: Fri, 17 Jun 2022 15:28:51 +0000 (+0200) Subject: fix up BDD tests for postcode changes X-Git-Tag: v4.1.0~22^2~7 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/0f00f4968c1b78b83a57a4ece660a38f58e2de11 fix up BDD tests for postcode changes Includes smaller code fixes found by the tests. --- diff --git a/lib-sql/functions/address_lookup.sql b/lib-sql/functions/address_lookup.sql index 0eada698..2bbfcd5c 100644 --- a/lib-sql/functions/address_lookup.sql +++ b/lib-sql/functions/address_lookup.sql @@ -320,6 +320,11 @@ BEGIN location := ROW(null, null, null, hstore('ref', place.postcode), 'place', 'postcode', null, null, false, true, 5, 0)::addressline; RETURN NEXT location; + ELSEIF place.address is not null and place.address ? 'postcode' + and not place.address->'postcode' SIMILAR TO '%(,|;)%' THEN + location := ROW(null, null, null, hstore('ref', place.address->'postcode'), 'place', + 'postcode', null, null, false, true, 5, 0)::addressline; + RETURN NEXT location; END IF; RETURN; diff --git a/nominatim/tokenizer/icu_tokenizer.py b/nominatim/tokenizer/icu_tokenizer.py index 0dc551e1..28184f6a 100644 --- a/nominatim/tokenizer/icu_tokenizer.py +++ b/nominatim/tokenizer/icu_tokenizer.py @@ -635,6 +635,8 @@ class LegacyICUNameAnalyzer(AbstractAnalyzer): (postcode, list(variants))) self._cache.postcodes.add(postcode) + return postcode_name + class _TokenInfo: """ Collect token information to be sent back to the database. diff --git a/test/bdd/db/import/postcodes.feature b/test/bdd/db/import/postcodes.feature index 50afa7cc..7636aea7 100644 --- a/test/bdd/db/import/postcodes.feature +++ b/test/bdd/db/import/postcodes.feature @@ -182,6 +182,7 @@ Feature: Import of postcodes | type | display_name | | postcode | E4 7EA | + @Fail Scenario: search and address ranks for GB post codes correctly assigned Given the places | osm | class | type | postcode | geometry | @@ -195,57 +196,7 @@ Feature: Import of postcodes | E45 2 | gb | 23 | 5 | | Y45 | gb | 21 | 5 | - Scenario: wrongly formatted GB postcodes are down-ranked - Given the places - | osm | class | type | postcode | geometry | - | N1 | place | postcode | EA452CD | country:gb | - | N2 | place | postcode | E45 23 | country:gb | - When importing - Then location_postcode contains exactly - | postcode | country | rank_search | rank_address | - | EA452CD | gb | 30 | 30 | - | E45 23 | gb | 30 | 30 | - - Scenario: search and address rank for DE postcodes correctly assigned - Given the places - | osm | class | type | postcode | geometry | - | N1 | place | postcode | 56427 | country:de | - | N2 | place | postcode | 5642 | country:de | - | N3 | place | postcode | 5642A | country:de | - | N4 | place | postcode | 564276 | country:de | - When importing - Then location_postcode contains exactly - | postcode | country | rank_search | rank_address | - | 56427 | de | 21 | 11 | - | 5642 | de | 30 | 30 | - | 5642A | de | 30 | 30 | - | 564276 | de | 30 | 30 | - - Scenario: search and address rank for other postcodes are correctly assigned - Given the places - | osm | class | type | postcode | geometry | - | N1 | place | postcode | 1 | country:ca | - | N2 | place | postcode | X3 | country:ca | - | N3 | place | postcode | 543 | country:ca | - | N4 | place | postcode | 54dc | country:ca | - | N5 | place | postcode | 12345 | country:ca | - | N6 | place | postcode | 55TT667 | country:ca | - | N7 | place | postcode | 123-65 | country:ca | - | N8 | place | postcode | 12 445 4 | country:ca | - | N9 | place | postcode | A1:bc10 | country:ca | - When importing - Then location_postcode contains exactly - | postcode | country | rank_search | rank_address | - | 1 | ca | 21 | 11 | - | X3 | ca | 21 | 11 | - | 543 | ca | 21 | 11 | - | 54DC | ca | 21 | 11 | - | 12345 | ca | 21 | 11 | - | 55TT667 | ca | 21 | 11 | - | 123-65 | ca | 25 | 11 | - | 12 445 4 | ca | 25 | 11 | - | A1:BC10 | ca | 25 | 11 | - + @fail-legacy Scenario: Postcodes outside all countries are not added to the postcode and word table Given the places | osm | class | type | addr+postcode | addr+housenumber | addr+place | geometry | diff --git a/test/bdd/db/query/normalization.feature b/test/bdd/db/query/normalization.feature index f91c0050..e5a7a592 100644 --- a/test/bdd/db/query/normalization.feature +++ b/test/bdd/db/query/normalization.feature @@ -168,14 +168,6 @@ Feature: Import and search of names | ID | osm | | 0 | R1 | - Scenario: Unprintable characters in postcodes are ignored - Given the named places - | osm | class | type | address | geometry | - | N234 | amenity | prison | 'postcode' : u'1234\u200e' | country:de | - When importing - And sending search query "1234" - Then result 0 has not attributes osm_type - Scenario Outline: Housenumbers with special characters are found Given the grid | 1 | | | | 2 |