|
@@ -25,10 +25,15 @@ class TestBingImagesEngine(SearxTestCase):
|
25
|
25
|
self.assertTrue('_EDGE_S' in params['cookies'])
|
26
|
26
|
self.assertTrue('fr-fr' in params['cookies']['_EDGE_S'])
|
27
|
27
|
|
|
28
|
+ dicto['language'] = 'fr'
|
|
29
|
+ params = bing_images.request(query, dicto)
|
|
30
|
+ self.assertTrue('_EDGE_S' in params['cookies'])
|
|
31
|
+ self.assertTrue('fr-fr' in params['cookies']['_EDGE_S'])
|
|
32
|
+
|
28
|
33
|
dicto['language'] = 'all'
|
29
|
34
|
params = bing_images.request(query, dicto)
|
30
|
35
|
self.assertTrue('_EDGE_S' in params['cookies'])
|
31
|
|
- self.assertTrue('en' in params['cookies']['_EDGE_S'])
|
|
36
|
+ self.assertTrue('en-us' in params['cookies']['_EDGE_S'])
|
32
|
37
|
|
33
|
38
|
def test_response(self):
|
34
|
39
|
self.assertRaises(AttributeError, bing_images.response, None)
|
|
@@ -86,3 +91,28 @@ class TestBingImagesEngine(SearxTestCase):
|
86
|
91
|
self.assertEqual(results[0]['content'], '')
|
87
|
92
|
self.assertEqual(results[0]['thumbnail_src'], 'thumb_url')
|
88
|
93
|
self.assertEqual(results[0]['img_src'], 'img_url')
|
|
94
|
+
|
|
95
|
+ def test_fetch_supported_languages(self):
|
|
96
|
+ html = """
|
|
97
|
+ <div>
|
|
98
|
+ <div id="region-section-content">
|
|
99
|
+ <ul class="b_vList">
|
|
100
|
+ <li>
|
|
101
|
+ <a href="https://bing...&setmkt=de-DE&s...">Germany</a>
|
|
102
|
+ <a href="https://bing...&setmkt=nb-NO&s...">Norway</a>
|
|
103
|
+ </li>
|
|
104
|
+ </ul>
|
|
105
|
+ <ul class="b_vList">
|
|
106
|
+ <li>
|
|
107
|
+ <a href="https://bing...&setmkt=es-AR&s...">Argentina</a>
|
|
108
|
+ </li>
|
|
109
|
+ </ul>
|
|
110
|
+ </div>
|
|
111
|
+ </div>
|
|
112
|
+ """
|
|
113
|
+ response = mock.Mock(text=html)
|
|
114
|
+ languages = list(bing_images._fetch_supported_languages(response))
|
|
115
|
+ self.assertEqual(len(languages), 3)
|
|
116
|
+ self.assertIn('de-DE', languages)
|
|
117
|
+ self.assertIn('no-NO', languages)
|
|
118
|
+ self.assertIn('es-AR', languages)
|