diff options
| author | Markus Heiser <markus.heiser@darmarit.de> | 2025-03-05 17:29:20 +0100 |
|---|---|---|
| committer | Markus Heiser <markus.heiser@darmarIT.de> | 2025-03-15 10:36:33 +0100 |
| commit | 8769b7c6d6d62b961d62b9454bd12f69fba298c8 (patch) | |
| tree | bdf58284b785169606060acc257db5c1e828b430 /tests/unit/test_engine_mariadb_server.py | |
| parent | d6ce29f7f05a2ff49e1b8566d49b9ca21c30936a (diff) | |
[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 <markus.heiser@darmarit.de>
Diffstat (limited to 'tests/unit/test_engine_mariadb_server.py')
| -rw-r--r-- | tests/unit/test_engine_mariadb_server.py | 30 |
1 files changed, 0 insertions, 30 deletions
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']) |