from collections import defaultdict import mock from searx.engines import stackoverflow from searx.testing import SearxTestCase class TestStackoverflowEngine(SearxTestCase): def test_request(self): query = 'test_query' dicto = defaultdict(dict) dicto['pageno'] = 0 params = stackoverflow.request(query, dicto) self.assertTrue('url' in params) self.assertTrue(query in params['url']) self.assertTrue('stackoverflow.com' in params['url']) def test_response(self): self.assertRaises(AttributeError, stackoverflow.response, None) self.assertRaises(AttributeError, stackoverflow.response, []) self.assertRaises(AttributeError, stackoverflow.response, '') self.assertRaises(AttributeError, stackoverflow.response, '[]') response = mock.Mock(text='') self.assertEqual(stackoverflow.response(response), []) html = """