from collections import defaultdict import mock from searx.engines import bing from searx.testing import SearxTestCase class TestBingEngine(SearxTestCase): def test_request(self): query = 'test_query' dicto = defaultdict(dict) dicto['pageno'] = 0 dicto['language'] = 'fr_FR' params = bing.request(query, dicto) self.assertTrue('url' in params) self.assertTrue(query in params['url']) self.assertTrue('bing.com' in params['url']) self.assertTrue('SRCHHPGUSR' in params['cookies']) self.assertTrue('fr' in params['cookies']['SRCHHPGUSR']) dicto['language'] = 'all' params = bing.request(query, dicto) self.assertTrue('SRCHHPGUSR' in params['cookies']) self.assertTrue('en' in params['cookies']['SRCHHPGUSR']) def test_response(self): self.assertRaises(AttributeError, bing.response, None) self.assertRaises(AttributeError, bing.response, []) self.assertRaises(AttributeError, bing.response, '') self.assertRaises(AttributeError, bing.response, '[]') response = mock.Mock(content='') self.assertEqual(bing.response(response), []) response = mock.Mock(content='') self.assertEqual(bing.response(response), []) html = """
This should be the content.
This should be the content.