# coding=utf-8 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 = u"""
test test test test test test test test
date testcategory テスト 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'], 'http://www.acgsou.com/show-torrentid.html') self.assertEqual(r['content'], u'Category: "testcategory テスト".') self.assertEqual(r['title'], u'torrentname テスト') self.assertEqual(r['filesize'], 1048576)