.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.search.checker.impl.Checker Class Reference

Public Member Functions

 __init__ (self, EngineProcessor processor)
 
 engineref_list (self)
 
 call_test (self, obj, test_description)
 
 call_tests (self, obj, test_descriptions)
 
ResultContainer search (self, SearchQuery search_query)
 
ResultContainerTests get_result_container_tests (self, str test_name, SearchQuery search_query)
 
 run_test (self, test_name)
 
 run (self)
 

Static Public Member Functions

 search_query_matrix_iterator (engineref_list, matrix)
 

Public Attributes

 processor = processor
 
 tests = self.processor.get_tests()
 
 test_results = TestResults()
 

Static Private Attributes

str __slots__ = 'processor', 'tests', 'test_results'
 

Detailed Description

Definition at line 354 of file impl.py.

Constructor & Destructor Documentation

◆ __init__()

searx.search.checker.impl.Checker.__init__ ( self,
EngineProcessor processor )

Definition at line 358 of file impl.py.

358 def __init__(self, processor: EngineProcessor):
359 self.processor = processor
360 self.tests = self.processor.get_tests()
361 self.test_results = TestResults()
362

Member Function Documentation

◆ call_test()

searx.search.checker.impl.Checker.call_test ( self,
obj,
test_description )

Definition at line 386 of file impl.py.

386 def call_test(self, obj, test_description):
387 if isinstance(test_description, (tuple, list)):
388 method, args = test_description[0], test_description[1:]
389 else:
390 method = test_description
391 args = ()
392 if isinstance(method, str) and hasattr(obj, method):
393 getattr(obj, method)(*args)
394 elif isinstance(method, types.FunctionType):
395 method(*args)
396 else:
397 self.test_results.add_error(
398 obj.test_name,
399 'method {!r} ({}) not found for {}'.format(method, method.__class__.__name__, obj.__class__.__name__),
400 )
401

◆ call_tests()

searx.search.checker.impl.Checker.call_tests ( self,
obj,
test_descriptions )

Definition at line 402 of file impl.py.

402 def call_tests(self, obj, test_descriptions):
403 for test_description in test_descriptions:
404 self.call_test(obj, test_description)
405

◆ engineref_list()

searx.search.checker.impl.Checker.engineref_list ( self)

Definition at line 364 of file impl.py.

364 def engineref_list(self):
365 engine_name = self.processor.engine_name
366 engine_category = self.processor.engine.categories[0]
367 return [EngineRef(engine_name, engine_category)]
368

Referenced by searx.search.models.SearchQuery.__copy__(), searx.search.models.SearchQuery.__eq__(), searx.search.models.SearchQuery.__hash__(), searx.search.models.SearchQuery.__repr__(), and searx.search.models.SearchQuery.categories().

+ Here is the caller graph for this function:

◆ get_result_container_tests()

ResultContainerTests searx.search.checker.impl.Checker.get_result_container_tests ( self,
str test_name,
SearchQuery search_query )

Definition at line 415 of file impl.py.

415 def get_result_container_tests(self, test_name: str, search_query: SearchQuery) -> ResultContainerTests:
416 result_container = self.search(search_query)
417 result_container_check = ResultContainerTests(self.test_results, test_name, search_query, result_container)
418 result_container_check.check_basic()
419 return result_container_check
420

◆ run()

searx.search.checker.impl.Checker.run ( self)

Definition at line 436 of file impl.py.

436 def run(self):
437 for test_name in self.tests:
438 self.run_test(test_name)
439 # clear cache
440 _download_and_check_if_image.cache_clear()
441 # force a garbage collector
442 gc.collect()

◆ run_test()

searx.search.checker.impl.Checker.run_test ( self,
test_name )

Definition at line 421 of file impl.py.

421 def run_test(self, test_name):
422 test_parameters = self.tests[test_name]
423 search_query_list = list(Checker.search_query_matrix_iterator(self.engineref_list, test_parameters['matrix']))
424 rct_list = [self.get_result_container_tests(test_name, search_query) for search_query in search_query_list]
425 stop_test = False
426 if 'result_container' in test_parameters:
427 for rct in rct_list:
428 stop_test = stop_test or rct.stop_test
429 if not rct.stop_test:
430 self.call_tests(rct, test_parameters['result_container'])
431 if not stop_test:
432 if 'test' in test_parameters:
433 checker_tests = CheckerTests(self.test_results, test_name, rct_list)
434 self.call_tests(checker_tests, test_parameters['test'])
435

◆ search()

ResultContainer searx.search.checker.impl.Checker.search ( self,
SearchQuery search_query )

Definition at line 406 of file impl.py.

406 def search(self, search_query: SearchQuery) -> ResultContainer:
407 result_container = ResultContainer()
408 engineref_category = search_query.engineref_list[0].category
409 params = self.processor.get_params(search_query, engineref_category)
410 if params is not None:
411 counter_inc('engine', search_query.engineref_list[0].name, 'search', 'count', 'sent')
412 self.processor.search(search_query.query, params, result_container, default_timer(), 5)
413 return result_container
414

◆ search_query_matrix_iterator()

searx.search.checker.impl.Checker.search_query_matrix_iterator ( engineref_list,
matrix )
static

Definition at line 370 of file impl.py.

370 def search_query_matrix_iterator(engineref_list, matrix):
371 p = []
372 for name, values in matrix.items():
373 if isinstance(values, (tuple, list)):
374 l = [(name, value) for value in values]
375 else:
376 l = [(name, values)]
377 p.append(l)
378
379 for kwargs in itertools.product(*p):
380 kwargs = dict(kwargs)
381 query = kwargs['query']
382 params = dict(kwargs)
383 del params['query']
384 yield SearchQuery(query, engineref_list, **params)
385

Member Data Documentation

◆ __slots__

str searx.search.checker.impl.Checker.__slots__ = 'processor', 'tests', 'test_results'
staticprivate

Definition at line 356 of file impl.py.

◆ processor

searx.search.checker.impl.Checker.processor = processor

Definition at line 359 of file impl.py.

◆ test_results

searx.search.checker.impl.Checker.test_results = TestResults()

◆ tests

searx.search.checker.impl.Checker.tests = self.processor.get_tests()

Definition at line 360 of file impl.py.


The documentation for this class was generated from the following file: