mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-03-11 05:14:07 +00:00
custom country config loads correctly
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
[pytest]
|
[pytest]
|
||||||
markers =
|
markers =
|
||||||
sanitizer_params
|
sanitizer_params,
|
||||||
|
custom_country_config
|
||||||
@@ -13,7 +13,9 @@ import pytest
|
|||||||
from nominatim.tools import country_info
|
from nominatim.tools import country_info
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@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)
|
country_info.setup_country_config(def_config)
|
||||||
|
|
||||||
@pytest.mark.parametrize("no_partitions", (True, False))
|
@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')),
|
assert result_set == {'us' : set(('us', 'us1', 'us2', 'United States')),
|
||||||
'fr' : set(('fr', 'Fra', 'Fren'))}
|
'fr' : set(('fr', 'Fra', 'Fren'))}
|
||||||
|
|
||||||
|
@pytest.mark.custom_country_config
|
||||||
def test_setup_country_config_languages_not_loaded(project_env, def_config):
|
def test_setup_country_config_languages_not_loaded(project_env):
|
||||||
(project_env.project_dir / 'country_settings.yaml').write_text("""
|
(project_env.project_dir / 'country_settings.yaml').write_text("""
|
||||||
de:
|
de:
|
||||||
partition: 3
|
partition: 3
|
||||||
names:
|
names:
|
||||||
name:
|
name:
|
||||||
default: Deutschland
|
default: Deutschland
|
||||||
""")
|
""")
|
||||||
country_info.setup_country_config(def_config)
|
country_info.setup_country_config(project_env)
|
||||||
assert country_info._COUNTRY_INFO._info.values() == {'de': {'partition': 3,
|
assert country_info._COUNTRY_INFO._info == {'de': {'partition': 3,
|
||||||
'languages': [], 'names': {'name': {'default': 'Deutschland'}}}}
|
'languages': [], 'names': {'name': {'default': 'Deutschland'}}}}
|
||||||
|
|
||||||
|
@pytest.mark.custom_country_config
|
||||||
def test_setup_country_config_name_not_loaded(project_env, def_config):
|
def test_setup_country_config_name_not_loaded(project_env):
|
||||||
(project_env.project_dir / 'country_settings.yaml').write_text("""
|
(project_env.project_dir / 'country_settings.yaml').write_text("""
|
||||||
de:
|
de:
|
||||||
partition: 3
|
partition: 3
|
||||||
languages: de
|
languages: de
|
||||||
names:
|
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,
|
assert country_info._COUNTRY_INFO._info == {'de': {'partition': 3,
|
||||||
'languages': 'de', 'names': {'name': {}}}}
|
'languages': ['de'], 'names': {'name': {}}}}
|
||||||
|
|
||||||
|
@pytest.mark.custom_country_config
|
||||||
def test_setup_country_config_names_not_loaded(project_env, def_config):
|
def test_setup_country_config_names_not_loaded(project_env):
|
||||||
(project_env.project_dir / 'country_settings.yaml').write_text("""
|
(project_env.project_dir / 'country_settings.yaml').write_text("""
|
||||||
de:
|
de:
|
||||||
partition: 3
|
partition: 3
|
||||||
languages: de
|
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,
|
assert country_info._COUNTRY_INFO._info == {'de': {'partition': 3,
|
||||||
'languages': 'de', 'names': {'name': {}}}}
|
'languages': ['de'], 'names': {'name': {}}}}
|
||||||
|
|||||||
Reference in New Issue
Block a user