]> git.openstreetmap.org Git - nominatim.git/commitdiff
custom country config loads correctly
authorTareq Al-Ahdal <tareqoalahdal@gmail.com>
Fri, 1 Apr 2022 13:46:56 +0000 (21:46 +0800)
committerTareq Al-Ahdal <tareqoalahdal@gmail.com>
Fri, 1 Apr 2022 13:46:56 +0000 (21:46 +0800)
test/python/pytest.ini
test/python/tools/test_country_info.py

index a3bfd1282b1e5189fdc67f1c078ac795156c7616..cfaaec01deafe678177ee979e4d48f1e1781857e 100644 (file)
@@ -1,3 +1,4 @@
 [pytest]
 markers =
-    sanitizer_params
+    sanitizer_params,
+    custom_country_config
\ No newline at end of file
index 949dc2066e28996e2ea8af807b1800ae3c2408ab..f08320655fdde3eb32e64c4519aee740f12e011b 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))
@@ -60,38 +62,40 @@ def test_create_country_names(temp_db_with_extensions, temp_db_conn, temp_db_cur
         assert result_set == {'us' : set(('us', 'us1', 'us2', 'United States')),
                               'fr' : set(('fr', 'Fra', 'Fren'))}
 
-
-def test_setup_country_config_languages_not_loaded(project_env, def_config):
+@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: 
+    names:
+        name:
             default: Deutschland
 """)
-    country_info.setup_country_config(def_config)
-    assert country_info._COUNTRY_INFO._info.values() == {'de': {'partition': 3,
+    country_info.setup_country_config(project_env)
+    assert country_info._COUNTRY_INFO._info == {'de': {'partition': 3, 
             'languages': [], 'names': {'name': {'default': 'Deutschland'}}}}
 
-
-def test_setup_country_config_name_not_loaded(project_env, def_config):
+@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.setup_country_config(def_config)
+""")
+    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': {}}}}
+            'languages': ['de'], 'names': {'name': {}}}}
 
-
-def test_setup_country_config_names_not_loaded(project_env, def_config):
+@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.setup_country_config(def_config)
+    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': {}}}}
+            'languages': ['de'], 'names': {'name': {}}}}