]> git.openstreetmap.org Git - nominatim.git/blobdiff - test/python/tools/test_add_osm_data.py
also enable flake for tests in github actions
[nominatim.git] / test / python / tools / test_add_osm_data.py
index c62758ec12beba737fb5e68656f7ba04deb7498e..38cf87c4b5c642c230a280e5f0aefd4be9876527 100644 (file)
@@ -1,3 +1,9 @@
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# This file is part of Nominatim. (https://nominatim.org)
+#
+# Copyright (C) 2025 by the Nominatim developer community.
+# For a full list of authors see the git log.
 """
 Tests for functions to add additional data to the database.
 """
 """
 Tests for functions to add additional data to the database.
 """
@@ -5,7 +11,8 @@ from pathlib import Path
 
 import pytest
 
 
 import pytest
 
-from nominatim.tools import add_osm_data
+from nominatim_db.tools import add_osm_data
+
 
 class CaptureGetUrl:
 
 
 class CaptureGetUrl:
 
@@ -18,10 +25,15 @@ class CaptureGetUrl:
         return '<xml></xml>'
 
 
         return '<xml></xml>'
 
 
-def test_import_osm_file_simple(table_factory, osm2pgsql_options, capfd):
-    table_factory('place', content=((1, ), ))
+@pytest.fixture(autouse=True)
+def setup_delete_postprocessing(temp_db_cursor):
+    temp_db_cursor.execute("""CREATE OR REPLACE FUNCTION flush_deleted_places()
+                              RETURNS INTEGER AS $$ SELECT 1 $$ LANGUAGE SQL""")
+
+
+def test_import_osm_file_simple(dsn, table_factory, osm2pgsql_options, capfd):
 
 
-    assert add_osm_data.add_data_from_file(Path('change.osm'), osm2pgsql_options) == 0
+    assert add_osm_data.add_data_from_file(dsn, Path('change.osm'), osm2pgsql_options) == 0
     captured = capfd.readouterr()
 
     assert '--append' in captured.out
     captured = capfd.readouterr()
 
     assert '--append' in captured.out
@@ -35,11 +47,11 @@ def test_import_osm_file_simple(table_factory, osm2pgsql_options, capfd):
 @pytest.mark.parametrize("osm_type", ['node', 'way', 'relation'])
 @pytest.mark.parametrize("main_api,url", [(True, 'https://www.openstreetmap.org/api'),
                                           (False, 'https://overpass-api.de/api/interpreter?')])
 @pytest.mark.parametrize("osm_type", ['node', 'way', 'relation'])
 @pytest.mark.parametrize("main_api,url", [(True, 'https://www.openstreetmap.org/api'),
                                           (False, 'https://overpass-api.de/api/interpreter?')])
-def test_import_osm_object_main_api(osm2pgsql_options, monkeypatch, capfd,
-                                    osm_type, main_api, url):
+def test_import_osm_object_main_api(dsn, osm2pgsql_options, monkeypatch,
+                                    capfd, osm_type, main_api, url):
     get_url_mock = CaptureGetUrl(monkeypatch)
 
     get_url_mock = CaptureGetUrl(monkeypatch)
 
-    add_osm_data.add_osm_object(osm_type, 4536, main_api, osm2pgsql_options)
+    add_osm_data.add_osm_object(dsn, osm_type, 4536, main_api, osm2pgsql_options)
     captured = capfd.readouterr()
 
     assert get_url_mock.url.startswith(url)
     captured = capfd.readouterr()
 
     assert get_url_mock.url.startswith(url)