diff options
author | Markus Heiser <markus.heiser@darmarIT.de> | 2019-12-24 15:42:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-24 15:42:05 +0100 |
commit | 38dad2e8e3b100711afe3ae942aaed5111841cd6 (patch) | |
tree | 51f1a35121155010411aa5970ef06aff80adf741 /tests/unit/engines/test_digbt.py | |
parent | 0ae86cd1685d244c83a6080a7816365096ab06f8 (diff) | |
parent | a395fb4a8d030d5b8fde496d2ae722bc034d3e32 (diff) | |
download | searxng-38dad2e8e3b100711afe3ae942aaed5111841cd6.tar.gz searxng-38dad2e8e3b100711afe3ae942aaed5111841cd6.zip |
Merge branch 'master' into ne/fix-infinite_scroll-with-vim_bindings
Diffstat (limited to 'tests/unit/engines/test_digbt.py')
-rw-r--r-- | tests/unit/engines/test_digbt.py | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/tests/unit/engines/test_digbt.py b/tests/unit/engines/test_digbt.py deleted file mode 100644 index 31c2ecabb..000000000 --- a/tests/unit/engines/test_digbt.py +++ /dev/null @@ -1,61 +0,0 @@ -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(text='<html></html>') - self.assertEqual(digbt.response(response), []) - - html = """ - <table class="table"> - <tr><td class="x-item"> - <div> - <a title="The Big Bang Theory" class="title" href="/The-Big-Bang-Theory-d2.html"> - The Big <span class="highlight">Bang</span> Theory - </a> - <span class="ctime"><span style="color:red;">4 hours ago</span></span> - </div> - <div class="files"> - <ul> - <li>The Big Bang Theory 2.9 GB</li> - <li>....</li> - </ul> - </div> - <div class="tail"> - Files: 1 Size: 2.9 GB Downloads: 1 Updated: <span style="color:red;">4 hours ago</span> - - <a class="title" href="magnet:?xt=urn:btih:a&dn=The+Big+Bang+Theory"> - <span class="glyphicon glyphicon-magnet"></span> magnet-link - </a> - - </div> - </td></tr> - </table> - """ - response = mock.Mock(text=html.encode('utf-8')) - results = digbt.response(response) - self.assertEqual(type(results), list) - self.assertEqual(len(results), 1) - self.assertEqual(results[0]['title'], 'The Big Bang Theory') - self.assertEqual(results[0]['url'], 'https://digbt.org/The-Big-Bang-Theory-d2.html') - self.assertEqual(results[0]['content'], 'The Big Bang Theory 2.9 GB ....') - self.assertEqual(results[0]['filesize'], 3113851289) - self.assertEqual(results[0]['magnetlink'], 'magnet:?xt=urn:btih:a&dn=The+Big+Bang+Theory') |