summaryrefslogtreecommitdiff
path: root/tests/unit/engines
diff options
context:
space:
mode:
authorrachmadani haryono <rachmadaniHaryono@users.noreply.github.com>2019-07-25 14:17:45 +0800
committerAlexandre Flament <alex@al-f.net>2019-07-25 08:17:45 +0200
commit3b1122c5fa1bbac49f6e0eb9ff69efb8dca996ea (patch)
tree5d1d8568eba55be56aef54da68b9fe64bab597f2 /tests/unit/engines
parent87baa74a863ac74ae4c86bbfcb04148ba7f70696 (diff)
downloadsearxng-3b1122c5fa1bbac49f6e0eb9ff69efb8dca996ea.tar.gz
searxng-3b1122c5fa1bbac49f6e0eb9ff69efb8dca996ea.zip
[fix] fix duden engine (#1594)
Diffstat (limited to 'tests/unit/engines')
-rw-r--r--tests/unit/engines/test_duden.py28
1 files changed, 17 insertions, 11 deletions
diff --git a/tests/unit/engines/test_duden.py b/tests/unit/engines/test_duden.py
index d9bbfef8b..52fc513d0 100644
--- a/tests/unit/engines/test_duden.py
+++ b/tests/unit/engines/test_duden.py
@@ -10,24 +10,30 @@ 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'])
+ data = [
+ [1, 'https://www.duden.de/suchen/dudenonline/Haus'],
+ [2, 'https://www.duden.de/suchen/dudenonline/Haus?search_api_fulltext=&page=1']
+ ]
+ for page_no, exp_res in data:
+ dic['pageno'] = page_no
+ params = duden.request(query, dic)
+ self.assertTrue('url' in params)
+ self.assertTrue(query in params['url'])
+ self.assertTrue('duden.de' in params['url'])
+ self.assertEqual(params['url'], exp_res)
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&auml;ndigen Artikel</a>
+ <section class="vignette">
+ <h2"> <a href="/rechtschreibung/Haus">
+ <strong>This is the title also here</strong>
+ </a> </h2>
+ <p>This is the content</p>
</section>
"""
-
resp = mock.Mock(text=html)
results = duden.response(resp)
@@ -36,6 +42,6 @@ class TestDudenEngine(SearxTestCase):
# testing result (dictionary entry)
r = results[0]
- self.assertEqual(r['url'], 'https://this.is.the.url/')
+ self.assertEqual(r['url'], 'https://www.duden.de/rechtschreibung/Haus')
self.assertEqual(r['title'], 'This is the title also here')
self.assertEqual(r['content'], 'This is the content')