from collections import defaultdict import mock from searx.engines import ina from searx.testing import SearxTestCase class TestInaEngine(SearxTestCase): def test_request(self): query = 'test_query' dicto = defaultdict(dict) dicto['pageno'] = 0 params = ina.request(query, dicto) self.assertTrue('url' in params) self.assertTrue(query in params['url']) self.assertTrue('ina.fr' in params['url']) def test_response(self): self.assertRaises(AttributeError, ina.response, None) self.assertRaises(AttributeError, ina.response, []) self.assertRaises(AttributeError, ina.response, '') self.assertRaises(AttributeError, ina.response, '[]') response = mock.Mock(text='{}') self.assertEqual(ina.response(response), []) response = mock.Mock(text='{"data": []}') self.assertEqual(ina.response(response), []) json = """ {"content":"\\t