adapt unit tests to changed function names

This commit is contained in:
Sarah Hoffmann 2022-09-28 17:41:16 +02:00
parent 0a73ed7d64
commit 5ec2c1b712
3 changed files with 21 additions and 6 deletions

View File

@ -40,7 +40,7 @@ class TestCliImportWithDb:
mock_func_factory(nominatim.data.country_info, 'setup_country_tables'),
mock_func_factory(nominatim.tools.database_import, 'import_osm_data'),
mock_func_factory(nominatim.tools.refresh, 'import_wikipedia_articles'),
mock_func_factory(nominatim.tools.refresh, 'import_osm_views_geotiff'),
mock_func_factory(nominatim.tools.refresh, 'import_secondary_importance'),
mock_func_factory(nominatim.tools.database_import, 'truncate_data_tables'),
mock_func_factory(nominatim.tools.database_import, 'load_data'),
mock_func_factory(nominatim.tools.database_import, 'create_tables'),

View File

@ -24,7 +24,6 @@ class TestRefresh:
@pytest.mark.parametrize("command,func", [
('address-levels', 'load_address_levels_from_config'),
('wiki-data', 'import_wikipedia_articles'),
('osm-views', 'import_osm_views_geotiff'),
('importance', 'recompute_importance'),
('website', 'setup_website'),
])
@ -72,8 +71,18 @@ class TestRefresh:
assert self.call_nominatim('refresh', '--wiki-data') == 1
def test_refresh_osm_views_geotiff_file_not_found(self):
assert self.call_nominatim('refresh', '--osm-views') == 1
def test_refresh_secondary_importance_file_not_found(self):
assert self.call_nominatim('refresh', '--secondary-importance') == 1
def test_refresh_secondary_importance_new_table(self, mock_func_factory):
mocks = [mock_func_factory(nominatim.tools.refresh, 'import_secondary_importance'),
mock_func_factory(nominatim.tools.refresh, 'create_functions')]
assert self.call_nominatim('refresh', '--secondary-importance') == 0
assert mocks[0].called == 1
assert mocks[1].called == 1
def test_refresh_importance_computed_after_wiki_import(self, monkeypatch):
calls = []

View File

@ -17,8 +17,14 @@ def test_refresh_import_wikipedia_not_existing(dsn):
assert refresh.import_wikipedia_articles(dsn, Path('.')) == 1
def test_refresh_import_osm_views_geotiff_not_existing(dsn):
assert refresh.import_osm_views_geotiff(dsn, Path('.')) == 1
def test_refresh_import_secondary_importance_non_existing(dsn):
assert refresh.import_secondary_importance(dsn, Path('.')) == 1
def test_refresh_import_secondary_importance_testdb(dsn, src_dir, temp_db_conn, temp_db_cursor):
temp_db_cursor.execute('CREATE EXTENSION postgis; CREATE EXTENSION postgis_raster')
assert refresh.import_secondary_importance(dsn, src_dir / 'test' / 'testdb') == 0
assert temp_db_conn.table_exists('secondary_importance')
@pytest.mark.parametrize("replace", (True, False))