From 2eb756c7aaf2ae1dcac8f2f89ec6ef038222d077 Mon Sep 17 00:00:00 2001 From: Adam Tauber Date: Tue, 16 Jun 2015 19:56:16 +0200 Subject: [PATCH] [enh] add search tests --- searx/tests/test_search.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 searx/tests/test_search.py diff --git a/searx/tests/test_search.py b/searx/tests/test_search.py new file mode 100644 index 000000000..89d0b620d --- /dev/null +++ b/searx/tests/test_search.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +from searx.search import score_results +from searx.testing import SearxTestCase + + +def fake_result(url='https://aa.bb/cc?dd=ee#ff', + title='aaa', + content='bbb', + engine='wikipedia'): + return {'url': url, + 'title': title, + 'content': content, + 'engine': engine} + + +class ScoreResultsTestCase(SearxTestCase): + + def test_empty(self): + self.assertEqual(score_results(dict()), []) + + def test_urlparse(self): + results = score_results(dict(a=[fake_result(url='https://aa.bb/cc?dd=ee#ff')])) + parsed_url = results[0]['parsed_url'] + self.assertEqual(parsed_url.query, 'dd=ee')