]> git.openstreetmap.org Git - nominatim.git/blobdiff - test/python/test_tools_admin.py
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / test / python / test_tools_admin.py
index a40a17dbb950f2f9fbf1f82d19bbaa164cfd81d8..bd47e0e4632ee76215f9aa61bcf6234a8c752c6a 100644 (file)
@@ -3,40 +3,39 @@ Tests for maintenance and analysis functions.
 """
 import pytest
 
 """
 import pytest
 
-from nominatim.db.connection import connect
 from nominatim.errors import UsageError
 from nominatim.tools import admin
 
 from nominatim.errors import UsageError
 from nominatim.tools import admin
 
-@pytest.fixture
-def db(temp_db, placex_table):
-    conn = connect('dbname=' + temp_db)
-    yield conn
-    conn.close()
+@pytest.fixture(autouse=True)
+def create_placex_table(placex_table):
+    """ All tests in this module require the placex table to be set up.
+    """
 
 
-def test_analyse_indexing_no_objects(db):
+
+def test_analyse_indexing_no_objects(temp_db_conn):
     with pytest.raises(UsageError):
     with pytest.raises(UsageError):
-        admin.analyse_indexing(db)
+        admin.analyse_indexing(temp_db_conn)
 
 
 @pytest.mark.parametrize("oid", ['1234', 'N123a', 'X123'])
 
 
 @pytest.mark.parametrize("oid", ['1234', 'N123a', 'X123'])
-def test_analyse_indexing_bad_osmid(db, oid):
+def test_analyse_indexing_bad_osmid(temp_db_conn, oid):
     with pytest.raises(UsageError):
     with pytest.raises(UsageError):
-        admin.analyse_indexing(db, osm_id=oid)
+        admin.analyse_indexing(temp_db_conn, osm_id=oid)
 
 
 
 
-def test_analyse_indexing_unknown_osmid(db):
+def test_analyse_indexing_unknown_osmid(temp_db_conn):
     with pytest.raises(UsageError):
     with pytest.raises(UsageError):
-        admin.analyse_indexing(db, osm_id='W12345674')
+        admin.analyse_indexing(temp_db_conn, osm_id='W12345674')
 
 
 
 
-def test_analyse_indexing_with_place_id(db, temp_db_cursor):
+def test_analyse_indexing_with_place_id(temp_db_conn, temp_db_cursor):
     temp_db_cursor.execute("INSERT INTO placex (place_id) VALUES(12345)")
 
     temp_db_cursor.execute("INSERT INTO placex (place_id) VALUES(12345)")
 
-    admin.analyse_indexing(db, place_id=12345)
+    admin.analyse_indexing(temp_db_conn, place_id=12345)
 
 
 
 
-def test_analyse_indexing_with_osm_id(db, temp_db_cursor):
+def test_analyse_indexing_with_osm_id(temp_db_conn, temp_db_cursor):
     temp_db_cursor.execute("""INSERT INTO placex (place_id, osm_type, osm_id)
                               VALUES(9988, 'N', 10000)""")
 
     temp_db_cursor.execute("""INSERT INTO placex (place_id, osm_type, osm_id)
                               VALUES(9988, 'N', 10000)""")
 
-    admin.analyse_indexing(db, osm_id='N10000')
+    admin.analyse_indexing(temp_db_conn, osm_id='N10000')