diff --git a/searx/engines/acgsou.py b/searx/engines/acgsou.py index ebe253649..c1d8cccfa 100644 --- a/searx/engines/acgsou.py +++ b/searx/engines/acgsou.py @@ -63,7 +63,7 @@ def response(resp): filesize = get_torrent_size(filesize, filesize_multiplier) except: pass - # I didn't add download/seed/leech count since as I figured out they are generated randowmly everytime + # I didn't add download/seed/leech count since as I figured out they are generated randomly everytime content = 'Category: "{category}".' content = content.format(category=category) diff --git a/tests/unit/engines/test_acgsou.py b/tests/unit/engines/test_acgsou.py new file mode 100644 index 000000000..2c3e6608f --- /dev/null +++ b/tests/unit/engines/test_acgsou.py @@ -0,0 +1,67 @@ +from collections import defaultdict +import mock +from searx.engines import acgsou +from searx.testing import SearxTestCase + + +class TestAcgsouEngine(SearxTestCase): + + def test_request(self): + query = 'test_query' + dic = defaultdict(dict) + dic['pageno'] = 1 + params = acgsou.request(query, dic) + self.assertTrue('url' in params) + self.assertTrue(query in params['url']) + self.assertTrue('acgsou.com' in params['url']) + + def test_response(self): + resp = mock.Mock(text='') + self.assertEqual(acgsou.response(resp), []) + + html = """ + + + + tablehead + + + + + + + + + + + + + +
datetestcategory + torrentname + 1MB + + 29 + + + + 211 + + + + 168 + + user
+ """ + + resp = mock.Mock(text=html) + results = acgsou.response(resp) + + self.assertEqual(type(results), list) + self.assertEqual(len(results), 1) + + r = results[0] + self.assertEqual(r['url'], 'https://www.acgsou.com/show-torrentid.html') + self.assertEqual(r['content'], 'Category: "testcategory".') + self.assertEqual(r['title'], 'torrentname') + self.assertEqual(r['filesize'], 1048576)