- 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': {}}}}
+ assert result_set == {'us': set(('us', 'us1', 'us2')),
+ 'fr': set(('fr', 'Fra', 'Fren'))}
+
+
+def test_setup_country_names_prefixes(env_with_country_config):
+ config = env_with_country_config("""\
+ es:
+ names:
+ name:
+ en: Spain
+ de: Spanien
+ default: Espagñe
+ us:
+ names:
+ short_name:
+ default: USA
+ name:
+ default: United States
+ en: United States
+ """)
+ info = country_info._CountryInfo()
+ info.load(config)
+
+ assert info.get('es')['names'] == {"name": "Espagñe",
+ "name:en": "Spain",
+ "name:de": "Spanien"}
+ assert info.get('us')['names'] == {"name": "United States",
+ "name:en": "United States",
+ "short_name": "USA"}
+ assert 'names' not in info.get('xx')
+
+
+def test_setup_country_config_languages_not_loaded(env_with_country_config):
+ config = env_with_country_config("""\
+ de:
+ partition: 3
+ names:
+ name:
+ default: Deutschland
+ """)
+ info = country_info._CountryInfo()
+ info.load(config)
+ assert dict(info.items()) == {'de': {'partition': 3,
+ 'languages': [],
+ 'names': {'name': 'Deutschland'}}}
+
+
+def test_setup_country_config_name_not_loaded(env_with_country_config):
+ config = env_with_country_config("""\
+ de:
+ partition: 3
+ languages: de
+ names:
+ """)
+
+ info = country_info._CountryInfo()
+ info.load(config)
+
+ assert dict(info.items()) == {'de': {'partition': 3,
+ 'languages': ['de'],
+ 'names': {}
+ }}
+
+
+def test_setup_country_config_names_not_loaded(env_with_country_config):
+ config = env_with_country_config("""
+ de:
+ partition: 3
+ languages: de
+ """)
+
+ info = country_info._CountryInfo()
+ info.load(config)
+
+ assert dict(info.items()) == {'de': {'partition': 3,
+ 'languages': ['de'],
+ 'names': {}
+ }}
+
+
+def test_setup_country_config_special_character(env_with_country_config):
+ config = env_with_country_config("""
+ bq:
+ partition: 250
+ languages: nl
+ names:
+ name:
+ default: "\\N"
+ """)
+
+ info = country_info._CountryInfo()
+ info.load(config)
+
+ assert dict(info.items()) == {'bq': {'partition': 250,
+ 'languages': ['nl'],
+ 'names': {'name': '\x85'}
+ }}