summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKirill Isakov <ukwt@ya.ru>2016-03-27 03:50:44 +0600
committerKirill Isakov <ukwt@ya.ru>2016-03-27 03:50:44 +0600
commitc1d456b1366e339b09bd3744b45bf80da1e7d808 (patch)
treef6b8c53b415a48bf2e94cccc4cce8c78f59a4f48 /tests
parent547b8a87653d87b8be85710275a66be1bec1e39c (diff)
downloadsearxng-c1d456b1366e339b09bd3744b45bf80da1e7d808.tar.gz
searxng-c1d456b1366e339b09bd3744b45bf80da1e7d808.zip
Add F-Droid search engine
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/engines/test_fdroid.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/unit/engines/test_fdroid.py b/tests/unit/engines/test_fdroid.py
new file mode 100644
index 000000000..d75f4f0b4
--- /dev/null
+++ b/tests/unit/engines/test_fdroid.py
@@ -0,0 +1,49 @@
+import mock
+from collections import defaultdict
+from searx.engines import fdroid
+from searx.testing import SearxTestCase
+
+
+class TestFdroidEngine(SearxTestCase):
+
+ def test_request(self):
+ query = 'test_query'
+ dic = defaultdict(dict)
+ dic['pageno'] = 1
+ params = fdroid.request(query, dic)
+ self.assertTrue('url' in params)
+ self.assertTrue(query in params['url'])
+ self.assertTrue('f-droid.org' in params['url'])
+
+ def test_response(self):
+ resp = mock.Mock(text='<html></html>')
+ self.assertEqual(fdroid.response(resp), [])
+
+ html = """
+ <a href="https://google.com/qwerty">
+ <div id="appheader">
+ <div style="float:left;padding-right:10px;">
+ <img src="http://example.com/image.png"
+ style="width:48px;border:none;">
+ </div>
+ <div style="float:right;">
+ <p>Details...</p>
+ </div>
+ <p style="color:#000000;">
+ <span style="font-size:20px;">Sample title</span>
+ <br>
+ Sample content
+ </p>
+ </div>
+ </a>
+ """
+
+ resp = mock.Mock(text=html)
+ results = fdroid.response(resp)
+
+ self.assertEqual(type(results), list)
+ self.assertEqual(len(results), 1)
+ self.assertEqual(results[0]['url'], 'https://google.com/qwerty')
+ self.assertEqual(results[0]['title'], 'Sample title')
+ self.assertEqual(results[0]['content'], 'Sample content')
+ self.assertEqual(results[0]['img_src'], 'http://example.com/image.png')