From 54f0ab1f3bd6bcd05eb2108a3a2eeaf5bd71ab61 Mon Sep 17 00:00:00 2001 From: marc Date: Tue, 10 Oct 2017 17:30:43 -0500 Subject: [PATCH] test fetch langauges function on bing images --- tests/unit/engines/test_bing_images.py | 32 +++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) 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 = """ +
+
+ + +
+
+ """ + 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)