diff options
| author | Kang-min Liu <gugod@gugod.org> | 2015-11-14 00:05:44 +0100 |
|---|---|---|
| committer | Kang-min Liu <gugod@gugod.org> | 2015-11-14 00:05:44 +0100 |
| commit | ac8759cd3ff99024864fd04d7c4bef5c3a00b971 (patch) | |
| tree | 30c3f8b61504532df926bbffedcc8df80a8e926e /searx/tests/test_results.py | |
| parent | c7c6c35ccd7373d2107b70b92badb9b70d31905f (diff) | |
| parent | e98aef6fc4954681e58d774203d522f0ae478004 (diff) | |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'searx/tests/test_results.py')
| -rw-r--r-- | searx/tests/test_results.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/searx/tests/test_results.py b/searx/tests/test_results.py new file mode 100644 index 000000000..274b5b37a --- /dev/null +++ b/searx/tests/test_results.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- + +from searx.results import ResultContainer +from searx.testing import SearxTestCase + + +def fake_result(url='https://aa.bb/cc?dd=ee#ff', + title='aaa', + content='bbb', + engine='wikipedia', **kwargs): + result = {'url': url, + 'title': title, + 'content': content, + 'engine': engine} + result.update(kwargs) + return result + + +# TODO +class ResultContainerTestCase(SearxTestCase): + + def test_empty(self): + c = ResultContainer() + self.assertEqual(c.get_ordered_results(), []) + + def test_one_result(self): + c = ResultContainer() + c.extend('wikipedia', [fake_result()]) + self.assertEqual(c.results_length(), 1) + + def test_one_suggestion(self): + c = ResultContainer() + c.extend('wikipedia', [fake_result(suggestion=True)]) + self.assertEqual(len(c.suggestions), 1) + self.assertEqual(c.results_length(), 0) + + def test_result_merge(self): + c = ResultContainer() + c.extend('wikipedia', [fake_result()]) + c.extend('wikidata', [fake_result(), fake_result(url='https://example.com/')]) + self.assertEqual(c.results_length(), 2) |