]> git.openstreetmap.org Git - nominatim.git/blobdiff - test/python/test_tokenizer_icu.py
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / test / python / test_tokenizer_icu.py
index 4d029dec6b1725553faf32d075a01f3f00010d85..5dbe292e38bcd73c869275ed225794adfaa2e76e 100644 (file)
@@ -7,7 +7,7 @@ import yaml
 import pytest
 
 from nominatim.tokenizer import icu_tokenizer
-from nominatim.tokenizer.icu_rule_loader import ICURuleLoader
+import nominatim.tokenizer.icu_rule_loader
 from nominatim.db import properties
 from nominatim.db.sql_preprocessor import SQLPreprocessor
 from nominatim.indexer.place_info import PlaceInfo
@@ -75,7 +75,7 @@ def analyzer(tokenizer_factory, test_config, monkeypatch,
                   'token-analysis': [{'analyzer': 'generic',
                                       'variants': [{'words': list(variants)}]}]}
         (test_config.project_dir / 'icu_tokenizer.yaml').write_text(yaml.dump(cfgstr))
-        tok.loader = ICURuleLoader(test_config)
+        tok.loader = nominatim.tokenizer.icu_rule_loader.ICURuleLoader(test_config)
 
         return tok.name_analyzer()
 
@@ -151,13 +151,12 @@ def getorcreate_hnr_id(temp_db_cursor):
                                 SELECT -nextval('seq_word')::INTEGER; $$ LANGUAGE SQL""")
 
 
-def test_init_new(tokenizer_factory, test_config, monkeypatch, db_prop):
-    monkeypatch.setenv('NOMINATIM_TERM_NORMALIZATION', ':: lower();')
-
+def test_init_new(tokenizer_factory, test_config, db_prop):
     tok = tokenizer_factory()
     tok.init_new_db(test_config)
 
-    assert db_prop(icu_tokenizer.DBCFG_TERM_NORMALIZATION) == ':: lower();'
+    assert db_prop(nominatim.tokenizer.icu_rule_loader.DBCFG_IMPORT_NORM_RULES) \
+            .startswith(':: lower ();')
 
 
 def test_init_word_table(tokenizer_factory, test_config, place_row, temp_db_cursor):
@@ -171,17 +170,14 @@ def test_init_word_table(tokenizer_factory, test_config, place_row, temp_db_curs
     assert temp_db_cursor.table_exists('word')
 
 
-def test_init_from_project(monkeypatch, test_config, tokenizer_factory):
-    monkeypatch.setenv('NOMINATIM_TERM_NORMALIZATION', ':: lower();')
+def test_init_from_project(test_config, tokenizer_factory):
     tok = tokenizer_factory()
     tok.init_new_db(test_config)
-    monkeypatch.undo()
 
     tok = tokenizer_factory()
     tok.init_from_project(test_config)
 
     assert tok.loader is not None
-    assert tok.term_normalization == ':: lower();'
 
 
 def test_update_sql_functions(db_prop, temp_db_cursor,