From 5ec2c1b7123bf0770075e12380c17959f2d95cff Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Wed, 28 Sep 2022 17:41:16 +0200 Subject: [PATCH] adapt unit tests to changed function names --- test/python/cli/test_cmd_import.py | 2 +- test/python/cli/test_cmd_refresh.py | 15 ++++++++++++--- test/python/tools/test_refresh.py | 10 ++++++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/test/python/cli/test_cmd_import.py b/test/python/cli/test_cmd_import.py index b6a8721f..d098e27e 100644 --- a/test/python/cli/test_cmd_import.py +++ b/test/python/cli/test_cmd_import.py @@ -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'), diff --git a/test/python/cli/test_cmd_refresh.py b/test/python/cli/test_cmd_refresh.py index 211c1d64..f3f93f0f 100644 --- a/test/python/cli/test_cmd_refresh.py +++ b/test/python/cli/test_cmd_refresh.py @@ -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 = [] diff --git a/test/python/tools/test_refresh.py b/test/python/tools/test_refresh.py index fa6e216e..3175cb97 100644 --- a/test/python/tools/test_refresh.py +++ b/test/python/tools/test_refresh.py @@ -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)) -- 2.45.1