diff options
| author | Adam Tauber <asciimoo@gmail.com> | 2016-01-02 11:14:49 +0100 |
|---|---|---|
| committer | Adam Tauber <asciimoo@gmail.com> | 2016-01-10 19:23:10 +0100 |
| commit | 53979a7bf7669c803c2a493fbf136519f6a293e6 (patch) | |
| tree | 3b79da9408699108ba89b22cedf73cfff1fe59b7 /tests/unit/test_results.py | |
| parent | f9186344b3642fb3d55d2dc46c96c6b25b8ccf41 (diff) | |
[mod] remove buildout/makefile infrastructure
Diffstat (limited to 'tests/unit/test_results.py')
| -rw-r--r-- | tests/unit/test_results.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/unit/test_results.py b/tests/unit/test_results.py new file mode 100644 index 000000000..274b5b37a --- /dev/null +++ b/tests/unit/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) |