X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/893490f94e19d113e46b89b3ae62492d40db4a7a..a33f2c0f5ba43df533b6e137f9151fe67feb20a1:/test/python/test_tokenizer_legacy.py diff --git a/test/python/test_tokenizer_legacy.py b/test/python/test_tokenizer_legacy.py index 58bf5a5e..80147172 100644 --- a/test/python/test_tokenizer_legacy.py +++ b/test/python/test_tokenizer_legacy.py @@ -35,7 +35,7 @@ def test_config(def_config, tmp_path): @pytest.fixture -def tokenizer_factory(dsn, tmp_path, monkeypatch, property_table): +def tokenizer_factory(dsn, tmp_path, property_table): (tmp_path / 'tokenizer').mkdir() def _maker(): @@ -43,6 +43,7 @@ def tokenizer_factory(dsn, tmp_path, monkeypatch, property_table): return _maker + @pytest.fixture def tokenizer_setup(tokenizer_factory, test_config, monkeypatch, sql_preprocessor): monkeypatch.setattr(legacy_tokenizer, '_check_module' , lambda m, c: None) @@ -208,7 +209,7 @@ def test_update_special_phrase_empty_table(analyzer, word_table, temp_db_cursor, ("König bei", "amenity", "royal", "near"), ("Könige", "amenity", "royal", "-"), ("strasse", "highway", "primary", "in") - ]) + ], True) assert temp_db_cursor.row_set("""SELECT word_token, word, class, type, operator FROM word WHERE class != 'place'""") \ @@ -225,11 +226,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'""") - analyzer.update_special_phrases([]) + analyzer.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, + make_standard_name): + 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'""") + + analyzer.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, make_standard_name): temp_db_cursor.execute("""INSERT INTO word (word_token, word, class, type, operator) @@ -242,7 +256,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'""") \