mirror of
				https://github.com/searxng/searxng.git
				synced 2025-10-30 18:22:31 -04:00 
			
		
		
		
	Continuation of #5147 .. typification of the engine processors. BTW: - removed obsolete engine property https_support - fixed & improved currency_convert - engine instances can now implement a engine.setup method [#5147] https://github.com/searxng/searxng/pull/5147 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
		
			
				
	
	
		
			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)
 | |
|         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)
 | |
|         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'])
 |