]> git.openstreetmap.org Git - nominatim.git/blobdiff - test/python/cursor.py
Merge pull request #3212 from lonvia/more-tests
[nominatim.git] / test / python / cursor.py
index 46069020b1cc07ba05ac6ef3d6535e502bbc4e50..73b83b1df840b3842bbb099ce9d5c2cc5c3af887 100644 (file)
@@ -1,3 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# This file is part of Nominatim. (https://nominatim.org)
+#
+# Copyright (C) 2022 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.
         """