mirror of
https://github.com/searx/searx
synced 2024-12-12 16:56:47 +01:00
update unit tests for google news and wikidata
This commit is contained in:
parent
b12857a70d
commit
9687786226
@ -42,7 +42,7 @@ class TestGoogleNewsEngine(SearxTestCase):
|
|||||||
<div class="ts _JGs _JHs _tJs _KGs _jHs">
|
<div class="ts _JGs _JHs _tJs _KGs _jHs">
|
||||||
<div class="_hJs">
|
<div class="_hJs">
|
||||||
<h3 class="r _gJs">
|
<h3 class="r _gJs">
|
||||||
<a class="l _PMs" href="https://example.com/" onmousedown="return rwt(this,'','','','11','AFQjCNEyehpzD5cJK1KUfXBx9RmsbqqG9g','','0ahUKEwjB58OR54HWAhWnKJoKHSQhAMY4ChCpAggiKAAwAA','','',event)">Example title</a>
|
<a class="l lLrAF" href="https://example.com/" onmousedown="return rwt(this,'','','','11','AFQjCNEyehpzD5cJK1KUfXBx9RmsbqqG9g','','0ahUKEwjB58OR54HWAhWnKJoKHSQhAMY4ChCpAggiKAAwAA','','',event)">Example title</a>
|
||||||
</h3>
|
</h3>
|
||||||
<div class="slp">
|
<div class="slp">
|
||||||
<span class="_OHs _PHs">
|
<span class="_OHs _PHs">
|
||||||
@ -63,7 +63,7 @@ class TestGoogleNewsEngine(SearxTestCase):
|
|||||||
</a>
|
</a>
|
||||||
<div class="_hJs">
|
<div class="_hJs">
|
||||||
<h3 class="r _gJs">
|
<h3 class="r _gJs">
|
||||||
<a class="l _PMs" href="https://example2.com/" onmousedown="return rwt(this,'','','','12','AFQjCNHObfH7sYmLWI1SC-YhWXKZFRzRjw','','0ahUKEwjB58OR54HWAhWnKJoKHSQhAMY4ChCpAgglKAAwAQ','','',event)">Example title 2</a>
|
<a class="l lLrAF" href="https://example2.com/" onmousedown="return rwt(this,'','','','12','AFQjCNHObfH7sYmLWI1SC-YhWXKZFRzRjw','','0ahUKEwjB58OR54HWAhWnKJoKHSQhAMY4ChCpAgglKAAwAQ','','',event)">Example title 2</a>
|
||||||
</h3>
|
</h3>
|
||||||
<div class="slp">
|
<div class="slp">
|
||||||
<span class="_OHs _PHs">
|
<span class="_OHs _PHs">
|
||||||
|
@ -9,20 +9,15 @@ from searx.testing import SearxTestCase
|
|||||||
class TestWikidataEngine(SearxTestCase):
|
class TestWikidataEngine(SearxTestCase):
|
||||||
|
|
||||||
def test_request(self):
|
def test_request(self):
|
||||||
wikidata.supported_languages = ['en', 'es']
|
|
||||||
query = 'test_query'
|
query = 'test_query'
|
||||||
dicto = defaultdict(dict)
|
dicto = defaultdict(dict)
|
||||||
dicto['language'] = 'en-US'
|
|
||||||
params = wikidata.request(query, dicto)
|
params = wikidata.request(query, dicto)
|
||||||
self.assertIn('url', params)
|
self.assertIn('url', params)
|
||||||
self.assertIn(query, params['url'])
|
self.assertIn(query, params['url'])
|
||||||
self.assertIn('wikidata.org', params['url'])
|
self.assertIn('wikidata.org', params['url'])
|
||||||
self.assertIn('en', params['url'])
|
|
||||||
|
|
||||||
dicto['language'] = 'es-ES'
|
|
||||||
params = wikidata.request(query, dicto)
|
params = wikidata.request(query, dicto)
|
||||||
self.assertIn(query, params['url'])
|
self.assertIn(query, params['url'])
|
||||||
self.assertIn('es', params['url'])
|
|
||||||
|
|
||||||
# successful cases are not tested here to avoid sending additional requests
|
# successful cases are not tested here to avoid sending additional requests
|
||||||
def test_response(self):
|
def test_response(self):
|
||||||
@ -31,6 +26,7 @@ class TestWikidataEngine(SearxTestCase):
|
|||||||
self.assertRaises(AttributeError, wikidata.response, '')
|
self.assertRaises(AttributeError, wikidata.response, '')
|
||||||
self.assertRaises(AttributeError, wikidata.response, '[]')
|
self.assertRaises(AttributeError, wikidata.response, '[]')
|
||||||
|
|
||||||
|
wikidata.supported_languages = ['en', 'es']
|
||||||
response = mock.Mock(text='<html></html>', search_params={"language": "en"})
|
response = mock.Mock(text='<html></html>', search_params={"language": "en"})
|
||||||
self.assertEqual(wikidata.response(response), [])
|
self.assertEqual(wikidata.response(response), [])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user