]> git.openstreetmap.org Git - nominatim.git/blobdiff - test/python/tools/test_country_info.py
separate unit test function into three functions
[nominatim.git] / test / python / tools / test_country_info.py
index 66f785c2622a6d9fe9c5967af18368681e7e1850..949dc2066e28996e2ea8af807b1800ae3c2408ab 100644 (file)
@@ -1,3 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# This file is part of Nominatim. (https://nominatim.org)
+#
+# Copyright (C) 2022 by the Nominatim developer community.
+# For a full list of authors see the git log.
 """
 Tests for function that handle country properties.
 """
@@ -53,3 +59,39 @@ 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'))}
+
+
+def test_setup_country_config_languages_not_loaded(project_env, def_config):
+    (project_env.project_dir / 'country_settings.yaml').write_text("""
+de:
+    partition: 3
+    names: 
+        name: 
+            default: Deutschland
+""")
+    country_info.setup_country_config(def_config)
+    assert country_info._COUNTRY_INFO._info.values() == {'de': {'partition': 3,
+            'languages': [], 'names': {'name': {'default': 'Deutschland'}}}}
+
+
+def test_setup_country_config_name_not_loaded(project_env, def_config):
+    (project_env.project_dir / 'country_settings.yaml').write_text("""
+de:
+    partition: 3
+    languages: de
+    names:
+""",)
+    country_info.setup_country_config(def_config)
+    assert country_info._COUNTRY_INFO._info == {'de': {'partition': 3,
+            'languages': 'de', 'names': {'name': {}}}}
+
+
+def test_setup_country_config_names_not_loaded(project_env, def_config):
+    (project_env.project_dir / 'country_settings.yaml').write_text("""
+de:
+    partition: 3
+    languages: de
+""")
+    country_info.setup_country_config(def_config)
+    assert country_info._COUNTRY_INFO._info == {'de': {'partition': 3,
+            'languages': 'de', 'names': {'name': {}}}}