diff options
author | dadosch <daniel-github@dadosch.de> | 2018-08-18 19:24:02 +0200 |
---|---|---|
committer | dadosch <daniel-github@dadosch.de> | 2018-08-18 19:24:02 +0200 |
commit | b575f898c0957475fcf6ecb179315b14617f39e1 (patch) | |
tree | 666ad08812866bee44564881af9ff4e86c9f70e0 /tests | |
parent | d377563723d2917fb7ee38c2f4cbdc4e19fb53ac (diff) | |
download | searxng-b575f898c0957475fcf6ecb179315b14617f39e1.tar.gz searxng-b575f898c0957475fcf6ecb179315b14617f39e1.zip |
duden.de engine
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/engines/test_duden.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/unit/engines/test_duden.py b/tests/unit/engines/test_duden.py new file mode 100644 index 000000000..d9bbfef8b --- /dev/null +++ b/tests/unit/engines/test_duden.py @@ -0,0 +1,41 @@ +from collections import defaultdict +import mock +from searx.engines import duden +from searx.testing import SearxTestCase +from datetime import datetime + + +class TestDudenEngine(SearxTestCase): + + def test_request(self): + query = 'Haus' + dic = defaultdict(dict) + dic['pageno'] = 1 + params = duden.request(query, dic) + self.assertTrue('url' in params) + self.assertTrue(query in params['url']) + self.assertTrue('duden.de' in params['url']) + + def test_response(self): + resp = mock.Mock(text='<html></html>') + self.assertEqual(duden.response(resp), []) + + html = """ + <section class="wide"> + <h2><a href="https://this.is.the.url/" class="hidden-link"><strong>This is the title</strong> also here</a></h2> + <p>This is the <strong>content</strong></p> + <a href="https://this.is.the.url/">Zum vollständigen Artikel</a> + </section> + """ + + resp = mock.Mock(text=html) + results = duden.response(resp) + + self.assertEqual(len(results), 1) + self.assertEqual(type(results), list) + + # testing result (dictionary entry) + r = results[0] + self.assertEqual(r['url'], 'https://this.is.the.url/') + self.assertEqual(r['title'], 'This is the title also here') + self.assertEqual(r['content'], 'This is the content') |