mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-03-11 05:14:07 +00:00
separate unit test function into three functions
This commit is contained in:
@@ -60,38 +60,38 @@ 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.parametrize("yaml_file_content", (
|
|
||||||
"""
|
def test_setup_country_config_languages_not_loaded(project_env, def_config):
|
||||||
|
(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)
|
||||||
|
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:
|
de:
|
||||||
partition: 3
|
partition: 3
|
||||||
languages: de
|
languages: de
|
||||||
names:
|
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:
|
de:
|
||||||
partition: 3
|
partition: 3
|
||||||
languages: de
|
languages: de
|
||||||
"""
|
""")
|
||||||
))
|
country_info.setup_country_config(def_config)
|
||||||
def test_load(project_env, def_config, yaml_file_content):
|
assert country_info._COUNTRY_INFO._info == {'de': {'partition': 3,
|
||||||
(project_env.project_dir / 'country_settings.yaml').write_text(yaml_file_content)
|
'languages': 'de', 'names': {'name': {}}}}
|
||||||
|
|
||||||
country_info._COUNTRY_INFO._info = def_config.load_sub_configuration(
|
|
||||||
(project_env.project_dir / 'country_settings.yaml'))
|
|
||||||
|
|
||||||
for prop in country_info._COUNTRY_INFO._info.values():
|
|
||||||
if 'languages' not in prop:
|
|
||||||
prop['languages'] = []
|
|
||||||
assert country_info._COUNTRY_INFO._info == {'de': {'partition': 3,
|
|
||||||
'languages': [], 'names': {'name': {'default': 'Deutschland'}}}}
|
|
||||||
if 'names' not in prop or prop['names'] is None:
|
|
||||||
prop['names'] = {'name': {}}
|
|
||||||
assert country_info._COUNTRY_INFO._info == {'de': {'partition': 3,
|
|
||||||
'languages': 'de', 'names': {'name': {}}}}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user