on master help sign in
update unit tests for google news and wikidata
9687786Marc Abonce Seguin
tests/unit/engines/test_google_news.py+2−2
@@ -42,7 +42,7 @@ class TestGoogleNewsEngine(SearxTestCase):
42 <div class="ts _JGs _JHs _tJs _KGs _jHs">
42 <div class="ts _JGs _JHs _tJs _KGs _jHs">
43 <div class="_hJs">
43 <div class="_hJs">
44 <h3 class="r _gJs">
44 <h3 class="r _gJs">
45− <a class="l _PMs" href="https://example.com/" onmousedown="return rwt(this,'','','','11','AFQjCNEyehpzD5cJK1KUfXBx9RmsbqqG9g','','0ahUKEwjB58OR54HWAhWnKJoKHSQhAMY4ChCpAggiKAAwAA','','',event)">Example title</a>
45+ <a class="l lLrAF" href="https://example.com/" onmousedown="return rwt(this,'','','','11','AFQjCNEyehpzD5cJK1KUfXBx9RmsbqqG9g','','0ahUKEwjB58OR54HWAhWnKJoKHSQhAMY4ChCpAggiKAAwAA','','',event)">Example title</a>
46 </h3>
46 </h3>
47 <div class="slp">
47 <div class="slp">
48 <span class="_OHs _PHs">
48 <span class="_OHs _PHs">
@@ -63,7 +63,7 @@ class TestGoogleNewsEngine(SearxTestCase):
63 </a>
63 </a>
64 <div class="_hJs">
64 <div class="_hJs">
65 <h3 class="r _gJs">
65 <h3 class="r _gJs">
66− <a class="l _PMs" href="https://example2.com/" onmousedown="return rwt(this,'','','','12','AFQjCNHObfH7sYmLWI1SC-YhWXKZFRzRjw','','0ahUKEwjB58OR54HWAhWnKJoKHSQhAMY4ChCpAgglKAAwAQ','','',event)">Example title 2</a>
66+ <a class="l lLrAF" href="https://example2.com/" onmousedown="return rwt(this,'','','','12','AFQjCNHObfH7sYmLWI1SC-YhWXKZFRzRjw','','0ahUKEwjB58OR54HWAhWnKJoKHSQhAMY4ChCpAgglKAAwAQ','','',event)">Example title 2</a>
67 </h3>
67 </h3>
68 <div class="slp">
68 <div class="slp">
69 <span class="_OHs _PHs">
69 <span class="_OHs _PHs">
tests/unit/engines/test_wikidata.py+1−5
@@ -9,20 +9,15 @@ from searx.testing import SearxTestCase
9class TestWikidataEngine(SearxTestCase):
9class TestWikidataEngine(SearxTestCase):
10
10
11 def test_request(self):
11 def test_request(self):
12− wikidata.supported_languages = ['en', 'es']
13 query = 'test_query'
12 query = 'test_query'
14 dicto = defaultdict(dict)
13 dicto = defaultdict(dict)
15− dicto['language'] = 'en-US'
16 params = wikidata.request(query, dicto)
14 params = wikidata.request(query, dicto)
17 self.assertIn('url', params)
15 self.assertIn('url', params)
18 self.assertIn(query, params['url'])
16 self.assertIn(query, params['url'])
19 self.assertIn('wikidata.org', params['url'])
17 self.assertIn('wikidata.org', params['url'])
20− self.assertIn('en', params['url'])
21
18
22− dicto['language'] = 'es-ES'
23 params = wikidata.request(query, dicto)
19 params = wikidata.request(query, dicto)
24 self.assertIn(query, params['url'])
20 self.assertIn(query, params['url'])
25− self.assertIn('es', params['url'])
26
21
27 # successful cases are not tested here to avoid sending additional requests
22 # successful cases are not tested here to avoid sending additional requests
28 def test_response(self):
23 def test_response(self):
@@ -31,6 +26,7 @@ class TestWikidataEngine(SearxTestCase):
31 self.assertRaises(AttributeError, wikidata.response, '')
26 self.assertRaises(AttributeError, wikidata.response, '')
32 self.assertRaises(AttributeError, wikidata.response, '[]')
27 self.assertRaises(AttributeError, wikidata.response, '[]')
33
28
29+ wikidata.supported_languages = ['en', 'es']
34 response = mock.Mock(text='<html></html>', search_params={"language": "en"})
30 response = mock.Mock(text='<html></html>', search_params={"language": "en"})
35 self.assertEqual(wikidata.response(response), [])
31 self.assertEqual(wikidata.response(response), [])
36
32