on master help sign in
update unit tests for google news and wikidata
commit96877862269f35aefc0b3ca7a7cb8812b1555dc4 authorMarc Abonce Seguin <marc-abonce@mailbox.org> dateSun 8 Apr 2018, 23:31 (9 years ago) parentb12857a
2 files changed+3−7
tests/unit/engines/test_google_news.py+2−2 tests/unit/engines/test_wikidata.py+1−5
tests/unit/engines/test_google_news.py+2−2
@@ -42,7 +42,7 @@ class TestGoogleNewsEngine(SearxTestCase):
4242 <div class="ts _JGs _JHs _tJs _KGs _jHs">
4343 <div class="_hJs">
4444 <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>
4646 </h3>
4747 <div class="slp">
4848 <span class="_OHs _PHs">
@@ -63,7 +63,7 @@ class TestGoogleNewsEngine(SearxTestCase):
6363 </a>
6464 <div class="_hJs">
6565 <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>
6767 </h3>
6868 <div class="slp">
6969 <span class="_OHs _PHs">
tests/unit/engines/test_wikidata.py+1−5
@@ -9,20 +9,15 @@ from searx.testing import SearxTestCase
99class TestWikidataEngine(SearxTestCase):
1010
1111 def test_request(self):
12− wikidata.supported_languages = ['en', 'es']
1312 query = 'test_query'
1413 dicto = defaultdict(dict)
15− dicto['language'] = 'en-US'
1614 params = wikidata.request(query, dicto)
1715 self.assertIn('url', params)
1816 self.assertIn(query, params['url'])
1917 self.assertIn('wikidata.org', params['url'])
20− self.assertIn('en', params['url'])
2118
22− dicto['language'] = 'es-ES'
2319 params = wikidata.request(query, dicto)
2420 self.assertIn(query, params['url'])
25− self.assertIn('es', params['url'])
2621
2722 # successful cases are not tested here to avoid sending additional requests
2823 def test_response(self):
@@ -31,6 +26,7 @@ class TestWikidataEngine(SearxTestCase):
3126 self.assertRaises(AttributeError, wikidata.response, '')
3227 self.assertRaises(AttributeError, wikidata.response, '[]')
3328
29+ wikidata.supported_languages = ['en', 'es']
3430 response = mock.Mock(text='<html></html>', search_params={"language": "en"})
3531 self.assertEqual(wikidata.response(response), [])
3632