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