mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-16 15:47:58 +00:00
correctly handle removing all postcodes for country
This commit is contained in:
@@ -251,7 +251,7 @@ def check_location_postcode(context):
|
||||
with context.db.cursor(cursor_factory=psycopg2.extras.DictCursor) as cur:
|
||||
cur.execute("SELECT *, ST_AsText(geometry) as geomtxt FROM location_postcode")
|
||||
assert cur.rowcount == len(list(context.table)), \
|
||||
"Postcode table has {} rows, expected {}.".foramt(cur.rowcount, len(list(context.table)))
|
||||
"Postcode table has {} rows, expected {}.".format(cur.rowcount, len(list(context.table)))
|
||||
|
||||
results = {}
|
||||
for row in cur:
|
||||
|
||||
@@ -54,7 +54,7 @@ class DummyNameAnalyzer:
|
||||
def normalize_postcode(self, postcode):
|
||||
return postcode
|
||||
|
||||
def add_postcodes_from_db(self):
|
||||
def update_postcodes_from_db(self):
|
||||
pass
|
||||
|
||||
def update_special_phrases(self, phrases):
|
||||
|
||||
@@ -71,8 +71,7 @@ def test_import_postcodes_add_new(dsn, placex_table, postcode_table, tmp_path, t
|
||||
|
||||
postcodes.update_postcodes(dsn, tmp_path, tokenizer)
|
||||
|
||||
assert postcode_table.row_set == {('xx', '9486', 10, 12),
|
||||
('yy', '9486', 99, 34)}
|
||||
assert postcode_table.row_set == {('xx', '9486', 10, 12), }
|
||||
|
||||
|
||||
def test_import_postcodes_replace_coordinates(dsn, placex_table, postcode_table, tmp_path, tokenizer):
|
||||
@@ -105,6 +104,14 @@ def test_import_postcodes_remove(dsn, placex_table, postcode_table, tmp_path, to
|
||||
assert postcode_table.row_set == {('xx', 'AB 4511', 10, 12)}
|
||||
|
||||
|
||||
def test_import_postcodes_remove_all(dsn, placex_table, postcode_table, tmp_path, tokenizer):
|
||||
postcode_table.add('ch', '5613', 10, 12)
|
||||
|
||||
postcodes.update_postcodes(dsn, tmp_path, tokenizer)
|
||||
|
||||
assert not postcode_table.row_set
|
||||
|
||||
|
||||
def test_import_postcodes_multi_country(dsn, placex_table, postcode_table, tmp_path, tokenizer):
|
||||
placex_table.add(country='de', geom='POINT(10 12)',
|
||||
address=dict(postcode='54451'))
|
||||
|
||||
Reference in New Issue
Block a user