1
0
mirror of https://github.com/searxng/searxng.git synced 2024-11-16 17:40:11 +01:00

Merge pull request #2682 from dalf/fix-checker

[fix] checker: various bug fixes
This commit is contained in:
Alexandre Flament 2021-03-27 17:44:29 +01:00 committed by GitHub
commit bb316d2698
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 8 deletions

View File

@ -111,8 +111,6 @@ class Search:
if request_params is None:
continue
request_params['engine_data'] = self.search_query.engine_data.get(engineref.name, {})
with threading.RLock():
processor.engine.stats['sent_search_count'] += 1

View File

@ -174,7 +174,7 @@ class ResultContainerTests:
@property
def result_urls(self):
results = self.result_container.get_ordered_results()
return [result['url'] for result in results]
return [result['url'] for result in results if 'url' in result]
def _record_error(self, message: str, *args) -> None:
sq = _search_query_to_dict(self.search_query)
@ -197,6 +197,8 @@ class ResultContainerTests:
self._record_error('HTML in title', repr(result.get('title', '')))
if not _check_no_html(result.get('content', '')):
self._record_error('HTML in content', repr(result.get('content', '')))
if result.get('url') is None:
self._record_error('url is None')
self._add_language(result.get('title', ''))
self._add_language(result.get('content', ''))
@ -310,7 +312,7 @@ class CheckerTests:
self.result_container_tests_list = result_container_tests_list
def unique_results(self):
"""Check the results of each ResultContain is unique"""
"""Check the results of each ResultContainer is unique"""
urls_list = [rct.result_urls for rct in self.result_container_tests_list]
if len(urls_list[0]) > 0:
# results on the first page

View File

@ -36,7 +36,7 @@ class SearchQuery:
time_range: typing.Optional[str]=None,
timeout_limit: typing.Optional[float]=None,
external_bang: typing.Optional[str]=None,
engine_data: typing.Optional[dict]=None):
engine_data: typing.Optional[typing.Dict[str, str]]=None):
self.query = query
self.engineref_list = engineref_list
self.lang = lang
@ -45,9 +45,7 @@ class SearchQuery:
self.time_range = time_range
self.timeout_limit = timeout_limit
self.external_bang = external_bang
self.engine_data = engine_data
if engine_data is None:
self.engine_data = {}
self.engine_data = engine_data or {}
@property
def categories(self):

View File

@ -27,6 +27,7 @@ class EngineProcessor(ABC):
params['pageno'] = search_query.pageno
params['safesearch'] = search_query.safesearch
params['time_range'] = search_query.time_range
params['engine_data'] = search_query.engine_data.get(self.engine_name, {})
if hasattr(self.engine, 'language') and self.engine.language:
params['language'] = self.engine.language