|
@@ -9,20 +9,15 @@ from searx.testing import SearxTestCase
|
9
|
9
|
class TestWikidataEngine(SearxTestCase):
|
10
|
10
|
|
11
|
11
|
def test_request(self):
|
12
|
|
- wikidata.supported_languages = ['en', 'es']
|
13
|
12
|
query = 'test_query'
|
14
|
13
|
dicto = defaultdict(dict)
|
15
|
|
- dicto['language'] = 'en-US'
|
16
|
14
|
params = wikidata.request(query, dicto)
|
17
|
15
|
self.assertIn('url', params)
|
18
|
16
|
self.assertIn(query, params['url'])
|
19
|
17
|
self.assertIn('wikidata.org', params['url'])
|
20
|
|
- self.assertIn('en', params['url'])
|
21
|
18
|
|
22
|
|
- dicto['language'] = 'es-ES'
|
23
|
19
|
params = wikidata.request(query, dicto)
|
24
|
20
|
self.assertIn(query, params['url'])
|
25
|
|
- self.assertIn('es', params['url'])
|
26
|
21
|
|
27
|
22
|
# successful cases are not tested here to avoid sending additional requests
|
28
|
23
|
def test_response(self):
|
|
@@ -31,6 +26,7 @@ class TestWikidataEngine(SearxTestCase):
|
31
|
26
|
self.assertRaises(AttributeError, wikidata.response, '')
|
32
|
27
|
self.assertRaises(AttributeError, wikidata.response, '[]')
|
33
|
28
|
|
|
29
|
+ wikidata.supported_languages = ['en', 'es']
|
34
|
30
|
response = mock.Mock(text='<html></html>', search_params={"language": "en"})
|
35
|
31
|
self.assertEqual(wikidata.response(response), [])
|
36
|
32
|
|