Browse Source

update unit tests for google news and wikidata

Marc Abonce Seguin 6 years ago
parent
commit
9687786226
2 changed files with 3 additions and 7 deletions
  1. 2
    2
      tests/unit/engines/test_google_news.py
  2. 1
    5
      tests/unit/engines/test_wikidata.py

+ 2
- 2
tests/unit/engines/test_google_news.py View File

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
                     </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">

+ 1
- 5
tests/unit/engines/test_wikidata.py View File

9
 class TestWikidataEngine(SearxTestCase):
9
 class 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
         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