From 8769b7c6d6d62b961d62b9454bd12f69fba298c8 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 5 Mar 2025 17:29:20 +0100 Subject: [refactor] typification of SearXNG (MainResult) / result items (part 2) The class ReslutContainer has been revised, it can now handle the typed Result items of classes: - MainResult - LegacyResult (a dict wrapper for backward compatibility) Due to the now complete typing of theses three clases, instead of the *getitem* accesses, the fields can now be accessed directly via attributes (which is also supported by the IDE). Signed-off-by: Markus Heiser --- tests/unit/test_engine_mariadb_server.py | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 tests/unit/test_engine_mariadb_server.py (limited to 'tests/unit/test_engine_mariadb_server.py') diff --git a/tests/unit/test_engine_mariadb_server.py b/tests/unit/test_engine_mariadb_server.py deleted file mode 100644 index 983b0ea06..000000000 --- a/tests/unit/test_engine_mariadb_server.py +++ /dev/null @@ -1,30 +0,0 @@ -# SPDX-License-Identifier: AGPL-3.0-or-later -# pylint: disable=missing-module-docstring,disable=missing-class-docstring,invalid-name - -from unittest.mock import MagicMock, Mock - -from searx.engines import mariadb_server -from tests import SearxTestCase - - -class MariadbServerTests(SearxTestCase): - - def test_init_no_query_str_raises(self): - self.assertRaises(ValueError, lambda: mariadb_server.init({})) - - def test_init_non_select_raises(self): - self.assertRaises(ValueError, lambda: mariadb_server.init({'query_str': 'foobar'})) - - def test_search_returns_results(self): - test_string = 'FOOBAR' - cursor_mock = MagicMock() - with cursor_mock as setup: # pylint: disable=not-context-manager - setup.__iter__ = Mock(return_value=iter([{test_string, 1}])) - setup.description = [[test_string]] - conn_mock = Mock() - conn_mock.cursor.return_value = cursor_mock - mariadb_server._connection = conn_mock # pylint: disable=protected-access - results = mariadb_server.search(test_string, {'pageno': 1}) - self.assertEqual(1, len(results)) - self.assertIn(test_string, results[0]) - self.assertEqual(mariadb_server.result_template, results[0]['template']) -- cgit v1.2.3