mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-16 15:47:58 +00:00
add fixtures for country table
This commit is contained in:
@@ -131,6 +131,20 @@ def project_env(tmp_path):
|
||||
return cfg
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def country_table(table_factory):
|
||||
table_factory('country_name', 'partition INT, country_code varchar(2), name hstore')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def country_row(country_table, temp_db_cursor):
|
||||
def _add(partition=None, country=None, names=None):
|
||||
temp_db_cursor.insert_row('country_name', partition=partition,
|
||||
country_code=country, name=names)
|
||||
|
||||
return _add
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def property_table(table_factory, temp_db_conn):
|
||||
table_factory('nominatim_properties', 'property TEXT, value TEXT')
|
||||
@@ -248,8 +262,10 @@ def osmline_table(temp_db_with_extensions, table_factory):
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sql_preprocessor_cfg(tmp_path, table_factory, temp_db_with_extensions):
|
||||
table_factory('country_name', 'partition INT', ((0, ), (1, ), (2, )))
|
||||
def sql_preprocessor_cfg(tmp_path, table_factory, temp_db_with_extensions, country_row):
|
||||
for part in range(3):
|
||||
country_row(partition=part)
|
||||
|
||||
cfg = Configuration(None)
|
||||
cfg.set_libdirs(sql=tmp_path)
|
||||
return cfg
|
||||
|
||||
@@ -53,11 +53,10 @@ def test_setup_country_tables(src_dir, temp_db_with_extensions, dsn, temp_db_cur
|
||||
|
||||
@pytest.mark.parametrize("languages", (None, ['fr', 'en']))
|
||||
def test_create_country_names(temp_db_with_extensions, temp_db_conn, temp_db_cursor,
|
||||
table_factory, tokenizer_mock, languages, loaded_country):
|
||||
|
||||
table_factory('country_name', 'country_code varchar(2), name hstore',
|
||||
content=(('us', '"name"=>"us1","name:af"=>"us2"'),
|
||||
('fr', '"name"=>"Fra", "name:en"=>"Fren"')))
|
||||
country_row, tokenizer_mock, languages, loaded_country):
|
||||
temp_db_cursor.execute('TRUNCATE country_name')
|
||||
country_row(country='us', names={"name": "us1", "name:af": "us2"})
|
||||
country_row(country='fr', names={"name": "Fra", "name:en": "Fren"})
|
||||
|
||||
assert temp_db_cursor.scalar("SELECT count(*) FROM country_name") == 2
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2025 by the Nominatim developer community.
|
||||
# Copyright (C) 2026 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Tests for maintenance and analysis functions.
|
||||
@@ -77,7 +77,7 @@ def test_analyse_indexing_with_osm_id(project_env, temp_db_cursor):
|
||||
class TestAdminCleanDeleted:
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup_polygon_delete(self, project_env, table_factory, place_table,
|
||||
def setup_polygon_delete(self, project_env, table_factory, country_table, place_table,
|
||||
osmline_table, temp_db_cursor, temp_db_conn, def_config, src_dir):
|
||||
""" Set up place_force_delete function and related tables
|
||||
"""
|
||||
@@ -104,7 +104,6 @@ class TestAdminCleanDeleted:
|
||||
class TEXT NOT NULL,
|
||||
type TEXT NOT NULL,
|
||||
deferred BOOLEAN""")
|
||||
table_factory('country_name', 'partition INT')
|
||||
table_factory('import_polygon_error', """osm_id BIGINT,
|
||||
osm_type CHAR(1),
|
||||
class TEXT NOT NULL,
|
||||
|
||||
Reference in New Issue
Block a user