@@ -10,24 +10,30 @@ class TestDudenEngine(SearxTestCase):
1010 def test_request(self):
1111 query = 'Haus'
1212 dic = defaultdict(dict)
13− dic['pageno'] = 1
14− params = duden.request(query, dic)
15− self.assertTrue('url' in params)
16− self.assertTrue(query in params['url'])
17− self.assertTrue('duden.de' in params['url'])
13+ data = [
14+ [1, 'https://www.duden.de/suchen/dudenonline/Haus'],
15+ [2, 'https://www.duden.de/suchen/dudenonline/Haus?search_api_fulltext=&page=1']
16+ ]
17+ for page_no, exp_res in data:
18+ dic['pageno'] = page_no
19+ params = duden.request(query, dic)
20+ self.assertTrue('url' in params)
21+ self.assertTrue(query in params['url'])
22+ self.assertTrue('duden.de' in params['url'])
23+ self.assertEqual(params['url'], exp_res)
1824
1925 def test_response(self):
2026 resp = mock.Mock(text='<html></html>')
2127 self.assertEqual(duden.response(resp), [])
2228
2329 html = """
24− <section class="wide">
25− <h2><a href="https://this.is.the.url/" class="hidden-link"><strong>This is the title</strong> also here</a></h2>
26− <p>This is the <strong>content</strong></p>
27− <a href="https://this.is.the.url/">Zum vollständigen Artikel</a>
30+ <section class="vignette">
31+ <h2"> <a href="/rechtschreibung/Haus">
32+ <strong>This is the title also here</strong>
33+ </a> </h2>
34+ <p>This is the content</p>
2835 </section>
2936 """
30−
3137 resp = mock.Mock(text=html)
3238 results = duden.response(resp)
3339
@@ -36,6 +42,6 @@ class TestDudenEngine(SearxTestCase):
3642
3743 # testing result (dictionary entry)
3844 r = results[0]
39− self.assertEqual(r['url'], 'https://this.is.the.url/')
45+ self.assertEqual(r['url'], 'https://www.duden.de/rechtschreibung/Haus')
4046 self.assertEqual(r['title'], 'This is the title also here')
4147 self.assertEqual(r['content'], 'This is the content')