X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/5e477e3b5b99da6fc4e54749d4671a6fc8fdcd66..0add25e33500110a36458a0bb3fa292d408d2b85:/test/python/mock_legacy_word_table.py 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."