mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-16 05:18:00 +00:00
Added --no-replace command for special phrases importation and added corresponding tests
This commit is contained in:
@@ -159,7 +159,7 @@ def test_update_special_phrase_empty_table(analyzer, word_table, temp_db_cursor)
|
||||
("König bei", "amenity", "royal", "near"),
|
||||
("Könige", "amenity", "royal", "-"),
|
||||
("street", "highway", "primary", "in")
|
||||
])
|
||||
], True)
|
||||
|
||||
assert temp_db_cursor.row_set("""SELECT word_token, word, class, type, operator
|
||||
FROM word WHERE class != 'place'""") \
|
||||
@@ -176,11 +176,24 @@ def test_update_special_phrase_delete_all(analyzer, word_table, temp_db_cursor):
|
||||
assert 2 == temp_db_cursor.scalar("SELECT count(*) FROM word WHERE class != 'place'""")
|
||||
|
||||
with analyzer() as a:
|
||||
a.update_special_phrases([])
|
||||
a.update_special_phrases([], True)
|
||||
|
||||
assert 0 == temp_db_cursor.scalar("SELECT count(*) FROM word WHERE class != 'place'""")
|
||||
|
||||
|
||||
def test_update_special_phrases_no_replace(analyzer, word_table, temp_db_cursor,):
|
||||
temp_db_cursor.execute("""INSERT INTO word (word_token, word, class, type, operator)
|
||||
VALUES (' FOO', 'foo', 'amenity', 'prison', 'in'),
|
||||
(' BAR', 'bar', 'highway', 'road', null)""")
|
||||
|
||||
assert 2 == temp_db_cursor.scalar("SELECT count(*) FROM word WHERE class != 'place'""")
|
||||
|
||||
with analyzer() as a:
|
||||
a.update_special_phrases([], False)
|
||||
|
||||
assert 2 == temp_db_cursor.scalar("SELECT count(*) FROM word WHERE class != 'place'""")
|
||||
|
||||
|
||||
def test_update_special_phrase_modify(analyzer, word_table, temp_db_cursor):
|
||||
temp_db_cursor.execute("""INSERT INTO word (word_token, word, class, type, operator)
|
||||
VALUES (' FOO', 'foo', 'amenity', 'prison', 'in'),
|
||||
@@ -193,7 +206,7 @@ def test_update_special_phrase_modify(analyzer, word_table, temp_db_cursor):
|
||||
('prison', 'amenity', 'prison', 'in'),
|
||||
('bar', 'highway', 'road', '-'),
|
||||
('garden', 'leisure', 'garden', 'near')
|
||||
])
|
||||
], True)
|
||||
|
||||
assert temp_db_cursor.row_set("""SELECT word_token, word, class, type, operator
|
||||
FROM word WHERE class != 'place'""") \
|
||||
|
||||
Reference in New Issue
Block a user