diff --git a/tests/unit/engines/test_digbt.py b/tests/unit/engines/test_digbt.py new file mode 100644 index 000000000..867188ed9 --- /dev/null +++ b/tests/unit/engines/test_digbt.py @@ -0,0 +1,59 @@ +from collections import defaultdict +import mock +from searx.engines import digbt +from searx.testing import SearxTestCase + + +class TestDigBTEngine(SearxTestCase): + + def test_request(self): + query = 'test_query' + dicto = defaultdict(dict) + dicto['pageno'] = 0 + params = digbt.request(query, dicto) + self.assertIn('url', params) + self.assertIn(query, params['url']) + self.assertIn('digbt.org', params['url']) + + def test_response(self): + self.assertRaises(AttributeError, digbt.response, None) + self.assertRaises(AttributeError, digbt.response, []) + self.assertRaises(AttributeError, digbt.response, '') + self.assertRaises(AttributeError, digbt.response, '[]') + + response = mock.Mock(content='') + self.assertEqual(digbt.response(response), []) + + html = """ +
+
+ The Big Bang Theory
+ 4 hours ago
+
+
+
+
+ Files: 1 Size: 2.9 GB Downloads: 1 Updated: 4 hours ago
+
+
+ magnet-link
+
+
+
+ |