X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/2bab0ca060ff224091b20a0ac808a3febaba04b1..c70dfccacac90a90bfc193f49262abe7505d7d75:/test/python/cursor.py diff --git a/test/python/cursor.py b/test/python/cursor.py index 7d586b3c..5dc93cd5 100644 --- a/test/python/cursor.py +++ b/test/python/cursor.py @@ -2,14 +2,15 @@ # # This file is part of Nominatim. (https://nominatim.org) # -# Copyright (C) 2024 by the Nominatim developer community. +# Copyright (C) 2025 by the Nominatim developer community. # For a full list of authors see the git log. """ -Specialised psycopg2 cursor with shortcut functions useful for testing. +Specialised psycopg cursor with shortcut functions useful for testing. """ -import psycopg2.extras +import psycopg -class CursorForTesting(psycopg2.extras.DictCursor): + +class CursorForTesting(psycopg.Cursor): """ Extension to the DictCursor class that provides execution short-cuts that simplify writing assertions. """ @@ -22,7 +23,6 @@ class CursorForTesting(psycopg2.extras.DictCursor): assert self.rowcount == 1 return self.fetchone()[0] - def row_set(self, sql, params=None): """ Execute a query and return the result as a set of tuples. Fails when the SQL command returns duplicate rows. @@ -34,7 +34,6 @@ class CursorForTesting(psycopg2.extras.DictCursor): return result - def table_exists(self, table): """ Check that a table with the given name exists in the database. """ @@ -42,7 +41,6 @@ class CursorForTesting(psycopg2.extras.DictCursor): WHERE tablename = %s""", (table, )) return num == 1 - def index_exists(self, table, index): """ Check that an indexwith the given name exists on the given table. """ @@ -51,7 +49,6 @@ class CursorForTesting(psycopg2.extras.DictCursor): (table, index)) return num == 1 - def table_rows(self, table, where=None): """ Return the number of rows in the given table. """ @@ -59,9 +56,3 @@ class CursorForTesting(psycopg2.extras.DictCursor): return self.scalar('SELECT count(*) FROM ' + table) return self.scalar('SELECT count(*) FROM {} WHERE {}'.format(table, where)) - - - def execute_values(self, *args, **kwargs): - """ Execute the execute_values() function on the cursor. - """ - psycopg2.extras.execute_values(self, *args, **kwargs)