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('language%3AFR' in params['url']) self.assertTrue('bing.com' in params['url']) dicto['language'] = 'all' params = bing.request(query, dicto) self.assertTrue('language' not in params['url']) 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(text='') self.assertEqual(bing.response(response), []) response = mock.Mock(text='') self.assertEqual(bing.response(response), []) html = """
This should be the content.
This should be the content.