@@ -10,24 +10,30 @@ class TestDudenEngine(SearxTestCase):
10 def test_request(self):
10 def test_request(self):
11 query = 'Haus'
11 query = 'Haus'
12 dic = defaultdict(dict)
12 dic = defaultdict(dict)
14+ [1, 'https://www.duden.de/suchen/dudenonline/Haus'],
15+ [2, 'https://www.duden.de/suchen/dudenonline/Haus?search_api_fulltext=&page=1']
17+ for page_no, exp_res in data:
13− dic['pageno'] = 1
18+ dic['pageno'] = page_no
14− params = duden.request(query, dic)
19+ params = duden.request(query, dic)
15− self.assertTrue('url' in params)
20+ self.assertTrue('url' in params)
16− self.assertTrue(query in params['url'])
21+ self.assertTrue(query in params['url'])
17− self.assertTrue('duden.de' in params['url'])
22+ self.assertTrue('duden.de' in params['url'])
23+ self.assertEqual(params['url'], exp_res)
19 def test_response(self):
25 def test_response(self):
20 resp = mock.Mock(text='<html></html>')
26 resp = mock.Mock(text='<html></html>')
21 self.assertEqual(duden.response(resp), [])
27 self.assertEqual(duden.response(resp), [])
23 html = """
29 html = """
24− <section class="wide">
30+ <section class="vignette">
31+ <h2"> <a href="/rechtschreibung/Haus">
25− <h2><a href="https://this.is.the.url/" class="hidden-link"><strong>This is the title</strong> also here</a></h2>
32+ <strong>This is the title also here</strong>
26− <p>This is the <strong>content</strong></p>
34+ <p>This is the content</p>
27− <a href="https://this.is.the.url/">Zum vollständigen Artikel</a>
28 </section>
35 </section>
31 resp = mock.Mock(text=html)
37 resp = mock.Mock(text=html)
32 results = duden.response(resp)
38 results = duden.response(resp)
@@ -36,6 +42,6 @@ class TestDudenEngine(SearxTestCase):
37 # testing result (dictionary entry)
43 # testing result (dictionary entry)
38 r = results[0]
44 r = results[0]
39− self.assertEqual(r['url'], 'https://this.is.the.url/')
45+ self.assertEqual(r['url'], 'https://www.duden.de/rechtschreibung/Haus')
40 self.assertEqual(r['title'], 'This is the title also here')
46 self.assertEqual(r['title'], 'This is the title also here')
41 self.assertEqual(r['content'], 'This is the content')
47 self.assertEqual(r['content'], 'This is the content')