]> git.openstreetmap.org Git - nominatim.git/blobdiff - test/python/tools/test_country_info.py
fix reset country info before loading custom data
[nominatim.git] / test / python / tools / test_country_info.py
index 2abb97cd3d57e5b56927623d895109b25178b74b..2651ebd3cfaa53f75b4674ea9480a5f0a2eb91ec 100644 (file)
@@ -13,7 +13,9 @@ import pytest
 from nominatim.tools import country_info
 
 @pytest.fixture(autouse=True)
-def read_config(def_config):
+def read_config(def_config, request):
+    if 'custom_country_config' in request.keywords:
+        return
     country_info.setup_country_config(def_config)
 
 @pytest.mark.parametrize("no_partitions", (True, False))
@@ -59,3 +61,42 @@ def test_create_country_names(temp_db_with_extensions, temp_db_conn, temp_db_cur
     else:
         assert result_set == {'us' : set(('us', 'us1', 'us2', 'United States')),
                               'fr' : set(('fr', 'Fra', 'Fren'))}
+
+@pytest.mark.custom_country_config
+def test_setup_country_config_languages_not_loaded(project_env):
+    (project_env.project_dir / 'country_settings.yaml').write_text("""
+de:
+    partition: 3
+    names:
+        name:
+            default: Deutschland
+""")
+    country_info._COUNTRY_INFO._info = None
+    country_info.setup_country_config(project_env)
+    assert country_info._COUNTRY_INFO._info == {'de': {'partition': 3, 
+            'languages': [], 'names': {'name': {'default': 'Deutschland'}}}}
+
+@pytest.mark.custom_country_config
+def test_setup_country_config_name_not_loaded(project_env):
+    (project_env.project_dir / 'country_settings.yaml').write_text("""
+de:
+    partition: 3
+    languages: de
+    names:
+""")
+    country_info._COUNTRY_INFO._info = None
+    country_info.setup_country_config(project_env)
+    assert country_info._COUNTRY_INFO._info == {'de': {'partition': 3,
+            'languages': ['de'], 'names': {'name': {}}}}
+
+@pytest.mark.custom_country_config
+def test_setup_country_config_names_not_loaded(project_env):
+    (project_env.project_dir / 'country_settings.yaml').write_text("""
+de:
+    partition: 3
+    languages: de
+""")
+    country_info._COUNTRY_INFO._info = None
+    country_info.setup_country_config(project_env)
+    assert country_info._COUNTRY_INFO._info == {'de': {'partition': 3,
+            'languages': ['de'], 'names': {'name': {}}}}