X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/efafa5271957fb54b356ec1c90e8613f14de40d4..968f1cd45393015975e658fc6b70065a3bfd3c94:/test/python/mock_legacy_word_table.py?ds=sidebyside diff --git a/test/python/mock_legacy_word_table.py b/test/python/mock_legacy_word_table.py index fa94d035..d3f81a4d 100644 --- a/test/python/mock_legacy_word_table.py +++ b/test/python/mock_legacy_word_table.py @@ -1,13 +1,14 @@ -# SPDX-License-Identifier: GPL-2.0-only +# SPDX-License-Identifier: GPL-3.0-or-later # # This file is part of Nominatim. (https://nominatim.org) # -# Copyright (C) 2022 by the Nominatim developer community. +# Copyright (C) 2024 by the Nominatim developer community. # For a full list of authors see the git log. """ Legacy word table for testing with functions to prefil and test contents of the table. """ +from nominatim_db.db.connection import execute_scalar class MockLegacyWordTable: """ A word table for testing using legacy word table structure. @@ -58,18 +59,16 @@ class MockLegacyWordTable: def count(self): - with self.conn.cursor() as cur: - return cur.scalar("SELECT count(*) FROM word") + return execute_scalar(self.conn, "SELECT count(*) FROM word") def count_special(self): - with self.conn.cursor() as cur: - return cur.scalar("SELECT count(*) FROM word WHERE class != 'place'") + return execute_scalar(self.conn, "SELECT count(*) FROM word WHERE class != 'place'") def get_special(self): with self.conn.cursor() as cur: - cur.execute("""SELECT word_token, word, class, type, operator + cur.execute("""SELECT word_token, word, class as cls, type, operator FROM word WHERE class != 'place'""") result = set((tuple(row) for row in cur)) assert len(result) == cur.rowcount, "Word table has duplicates."