summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarc <a01200356@itesm.mx>2017-10-10 17:30:43 -0500
committermarc <a01200356@itesm.mx>2017-10-10 18:37:24 -0500
commit54f0ab1f3bd6bcd05eb2108a3a2eeaf5bd71ab61 (patch)
tree12efd49d3548f2c1804dd128f44fa494d248bb33
parent44085e31d0ccf140f307389bd42654f5ada8667f (diff)
downloadsearxng-54f0ab1f3bd6bcd05eb2108a3a2eeaf5bd71ab61.tar.gz
searxng-54f0ab1f3bd6bcd05eb2108a3a2eeaf5bd71ab61.zip
test fetch langauges function on bing images
-rw-r--r--tests/unit/engines/test_bing_images.py32
1 files changed, 31 insertions, 1 deletions
diff --git a/tests/unit/engines/test_bing_images.py b/tests/unit/engines/test_bing_images.py
index 8b0bdb39d..3f3006124 100644
--- a/tests/unit/engines/test_bing_images.py
+++ b/tests/unit/engines/test_bing_images.py
@@ -25,10 +25,15 @@ class TestBingImagesEngine(SearxTestCase):
self.assertTrue('_EDGE_S' in params['cookies'])
self.assertTrue('fr-fr' in params['cookies']['_EDGE_S'])
+ dicto['language'] = 'fr'
+ params = bing_images.request(query, dicto)
+ self.assertTrue('_EDGE_S' in params['cookies'])
+ self.assertTrue('fr-fr' in params['cookies']['_EDGE_S'])
+
dicto['language'] = 'all'
params = bing_images.request(query, dicto)
self.assertTrue('_EDGE_S' in params['cookies'])
- self.assertTrue('en' in params['cookies']['_EDGE_S'])
+ self.assertTrue('en-us' in params['cookies']['_EDGE_S'])
def test_response(self):
self.assertRaises(AttributeError, bing_images.response, None)
@@ -86,3 +91,28 @@ class TestBingImagesEngine(SearxTestCase):
self.assertEqual(results[0]['content'], '')
self.assertEqual(results[0]['thumbnail_src'], 'thumb_url')
self.assertEqual(results[0]['img_src'], 'img_url')
+
+ def test_fetch_supported_languages(self):
+ html = """
+ <div>
+ <div id="region-section-content">
+ <ul class="b_vList">
+ <li>
+ <a href="https://bing...&setmkt=de-DE&s...">Germany</a>
+ <a href="https://bing...&setmkt=nb-NO&s...">Norway</a>
+ </li>
+ </ul>
+ <ul class="b_vList">
+ <li>
+ <a href="https://bing...&setmkt=es-AR&s...">Argentina</a>
+ </li>
+ </ul>
+ </div>
+ </div>
+ """
+ response = mock.Mock(text=html)
+ languages = list(bing_images._fetch_supported_languages(response))
+ self.assertEqual(len(languages), 3)
+ self.assertIn('de-DE', languages)
+ self.assertIn('no-NO', languages)
+ self.assertIn('es-AR', languages)