mirror of
https://github.com/searxng/searxng.git
synced 2025-10-19 13:00:36 -04:00
- pyright configuration [1]_ - stub files: types-lxml [2]_ - addition of various type hints - enable use of new type system features on older Python versions [3]_ - ``.tool-versions`` - set python to lowest version we support (3.10.18) [4]_: Older versions typically lack some typing features found in newer Python versions. Therefore, for local type checking (before commit), it is necessary to use the older Python interpreter. .. [1] https://docs.basedpyright.com/v1.20.0/configuration/config-files/ .. [2] https://pypi.org/project/types-lxml/ .. [3] https://typing-extensions.readthedocs.io/en/latest/# .. [4] https://mise.jdx.dev/configuration.html#tool-versions Signed-off-by: Markus Heiser <markus.heiser@darmarit.de> Format: reST
39 lines
1.6 KiB
Python
39 lines
1.6 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
# pylint: disable=missing-module-docstring,disable=missing-class-docstring,invalid-name
|
|
|
|
from searx.search.models import EngineRef, SearchQuery
|
|
from searx.search.processors import online
|
|
from searx import engines
|
|
|
|
from tests import SearxTestCase
|
|
|
|
TEST_ENGINE_NAME = "dummy engine" # from the ./settings/test_settings.yml
|
|
|
|
|
|
class TestOnlineProcessor(SearxTestCase):
|
|
|
|
def _get_params(self, online_processor, search_query, engine_category):
|
|
params = online_processor.get_params(search_query, engine_category)
|
|
self.assertIsNotNone(params)
|
|
assert params is not None
|
|
return params
|
|
|
|
def test_get_params_default_params(self):
|
|
engine = engines.engines[TEST_ENGINE_NAME]
|
|
online_processor = online.OnlineProcessor(engine, TEST_ENGINE_NAME)
|
|
search_query = SearchQuery('test', [EngineRef(TEST_ENGINE_NAME, 'general')], 'all', 0, 1, None, None, None)
|
|
params = self._get_params(online_processor, search_query, 'general')
|
|
self.assertIn('method', params)
|
|
self.assertIn('headers', params)
|
|
self.assertIn('data', params)
|
|
self.assertIn('url', params)
|
|
self.assertIn('cookies', params)
|
|
self.assertIn('auth', params)
|
|
|
|
def test_get_params_useragent(self):
|
|
engine = engines.engines[TEST_ENGINE_NAME]
|
|
online_processor = online.OnlineProcessor(engine, TEST_ENGINE_NAME)
|
|
search_query = SearchQuery('test', [EngineRef(TEST_ENGINE_NAME, 'general')], 'all', 0, 1, None, None, None)
|
|
params = self._get_params(online_processor, search_query, 'general')
|
|
self.assertIn('User-Agent', params['headers'])
|