+# 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.
"""
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))
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': {}}}}