diff options
author | Alexandre Flament <alex@al-f.net> | 2019-08-05 15:57:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-05 15:57:33 +0200 |
commit | 12f891da8496fad1f1fa24eeb52b1b19f03f8678 (patch) | |
tree | fe054e6a10efe9496419fbcd7b3d8a918be52a17 /tests/unit | |
parent | 91a59ff3502803611953820e2923348440f807d0 (diff) | |
parent | 1cee2c1796f50b2646c8dee0fcc5e9df754c9246 (diff) | |
download | searxng-12f891da8496fad1f1fa24eeb52b1b19f03f8678.tar.gz searxng-12f891da8496fad1f1fa24eeb52b1b19f03f8678.zip |
Merge pull request #1669 from dalf/engine-fixes
Engine fixes
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/engines/test_arxiv.py | 2 | ||||
-rw-r--r-- | tests/unit/engines/test_fdroid.py | 55 |
2 files changed, 34 insertions, 23 deletions
diff --git a/tests/unit/engines/test_arxiv.py b/tests/unit/engines/test_arxiv.py index b32c0e605..83c4f8595 100644 --- a/tests/unit/engines/test_arxiv.py +++ b/tests/unit/engines/test_arxiv.py @@ -8,7 +8,7 @@ from searx.testing import SearxTestCase class TestBaseEngine(SearxTestCase): def test_request(self): - query = 'test_query' + query = 'test_query'.encode('utf-8') dicto = defaultdict(dict) dicto['pageno'] = 1 params = arxiv.request(query, dicto) diff --git a/tests/unit/engines/test_fdroid.py b/tests/unit/engines/test_fdroid.py index d75f4f0b4..42a0a7148 100644 --- a/tests/unit/engines/test_fdroid.py +++ b/tests/unit/engines/test_fdroid.py @@ -13,29 +13,40 @@ class TestFdroidEngine(SearxTestCase): params = fdroid.request(query, dic) self.assertTrue('url' in params) self.assertTrue(query in params['url']) - self.assertTrue('f-droid.org' in params['url']) + self.assertTrue('search.f-droid.org' in params['url']) - def test_response(self): + def test_response_empty(self): resp = mock.Mock(text='<html></html>') self.assertEqual(fdroid.response(resp), []) + def test_response_oneresult(self): 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> +<!DOCTYPE html> +<html> +<head> + <title>test</title> +</head> +<body> + <div class="site-wrapper"> + <div class="main-content"> + <a class="package-header" href="https://example.com/app.url"> + <img class="package-icon" src="https://example.com/appexample.logo.png" /> + + <div class="package-info"> + <h4 class="package-name"> + App Example 1 + </h4> + + <div class="package-desc"> + <span class="package-summary">Description App Example 1</span> + <span class="package-license">GPL-3.0-only</span> + </div> + </div> + </a> + </div> + </div> +</body> +</html> """ resp = mock.Mock(text=html) @@ -43,7 +54,7 @@ class TestFdroidEngine(SearxTestCase): 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') + self.assertEqual(results[0]['url'], 'https://example.com/app.url') + self.assertEqual(results[0]['title'], 'App Example 1') + self.assertEqual(results[0]['content'], 'Description App Example 1 - GPL-3.0-only') + self.assertEqual(results[0]['img_src'], 'https://example.com/appexample.logo.png') |