X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/10143e0ac712913d0c33b5df4a4371e7ef849f06..fa1c402b47bdd1f76b8528885c0e3a5e90731cdc:/test/python/cursor.py diff --git a/test/python/cursor.py b/test/python/cursor.py index 46069020..7d586b3c 100644 --- a/test/python/cursor.py +++ b/test/python/cursor.py @@ -1,3 +1,9 @@ +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This file is part of Nominatim. (https://nominatim.org) +# +# Copyright (C) 2024 by the Nominatim developer community. +# For a full list of authors see the git log. """ Specialised psycopg2 cursor with shortcut functions useful for testing. """ @@ -37,6 +43,15 @@ class CursorForTesting(psycopg2.extras.DictCursor): return num == 1 + def index_exists(self, table, index): + """ Check that an indexwith the given name exists on the given table. + """ + num = self.scalar("""SELECT count(*) FROM pg_indexes + WHERE tablename = %s and indexname = %s""", + (table, index)) + return num == 1 + + def table_rows(self, table, where=None): """ Return the number of rows in the given table. """