@pytest.fixture
def make_standard_name(temp_db_cursor):
temp_db_cursor.execute("""CREATE OR REPLACE FUNCTION make_standard_name(name TEXT)
- RETURNS TEXT AS $$ SELECT ' ' || name; $$ LANGUAGE SQL""")
+ RETURNS TEXT AS $$ SELECT '#' || lower(name) || '#'; $$ LANGUAGE SQL""")
@pytest.fixture
analyzer.update_special_phrases([
("König bei", "amenity", "royal", "near"),
("Könige", "amenity", "royal", "-"),
+ ("könige", "amenity", "royal", "-"),
("strasse", "highway", "primary", "in")
], True)
assert word_table.get_special() \
- == set(((' könig bei', 'könig bei', 'amenity', 'royal', 'near'),
- (' könige', 'könige', 'amenity', 'royal', None),
- (' strasse', 'strasse', 'highway', 'primary', 'in')))
+ == set(((' #könig bei#', 'könig bei', 'amenity', 'royal', 'near'),
+ (' #könige#', 'könige', 'amenity', 'royal', None),
+ (' #strasse#', 'strasse', 'highway', 'primary', 'in')))
def test_update_special_phrase_delete_all(analyzer, word_table, make_standard_name):
- word_table.add_special(' foo', 'foo', 'amenity', 'prison', 'in')
- word_table.add_special(' bar', 'bar', 'highway', 'road', None)
+ word_table.add_special(' #foo#', 'foo', 'amenity', 'prison', 'in')
+ word_table.add_special(' #bar#', 'bar', 'highway', 'road', None)
assert word_table.count_special() == 2
def test_update_special_phrases_no_replace(analyzer, word_table, make_standard_name):
- word_table.add_special(' foo', 'foo', 'amenity', 'prison', 'in')
- word_table.add_special(' bar', 'bar', 'highway', 'road', None)
+ word_table.add_special(' #foo#', 'foo', 'amenity', 'prison', 'in')
+ word_table.add_special(' #bar#', 'bar', 'highway', 'road', None)
assert word_table.count_special() == 2
def test_update_special_phrase_modify(analyzer, word_table, make_standard_name):
- word_table.add_special(' foo', 'foo', 'amenity', 'prison', 'in')
- word_table.add_special(' bar', 'bar', 'highway', 'road', None)
+ word_table.add_special(' #foo#', 'foo', 'amenity', 'prison', 'in')
+ word_table.add_special(' #bar#', 'bar', 'highway', 'road', None)
assert word_table.count_special() == 2
], True)
assert word_table.get_special() \
- == set(((' prison', 'prison', 'amenity', 'prison', 'in'),
- (' bar', 'bar', 'highway', 'road', None),
- (' garden', 'garden', 'leisure', 'garden', 'near')))
+ == set(((' #prison#', 'prison', 'amenity', 'prison', 'in'),
+ (' #bar#', 'bar', 'highway', 'road', None),
+ (' #garden#', 'garden', 'leisure', 'garden', 'near')))
+
+
+def test_add_country_names(analyzer, word_table, make_standard_name):
+ analyzer.add_country_names('de', {'name': 'Germany',
+ 'name:de': 'Deutschland',
+ 'short_name': 'germany'})
+
+ assert word_table.get_country() \
+ == {('de', ' #germany#'),
+ ('de', ' #deutschland#')}
+
+
+def test_add_more_country_names(analyzer, word_table, make_standard_name):
+ word_table.add_country('fr', ' #france#')
+ word_table.add_country('it', ' #italy#')
+ word_table.add_country('it', ' #itala#')
+
+ analyzer.add_country_names('it', {'name': 'Italy', 'ref': 'IT'})
+
+ assert word_table.get_country() \
+ == {('fr', ' #france#'),
+ ('it', ' #italy#'),
+ ('it', ' #itala#'),
+ ('it', ' #it#')}
def test_process_place_names(analyzer, make_keywords):