From dcc9fdb47fd16aa65216846dc52470ada016753c Mon Sep 17 00:00:00 2001 From: rinpatch Date: Fri, 27 Apr 2018 15:36:15 +0300 Subject: Added unit test --- tests/unit/engines/test_acgsou.py | 67 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 tests/unit/engines/test_acgsou.py (limited to 'tests') 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) -- cgit v1.2.3 From 1ac0c90037923c06a337b7236b678d8ca2b45e5f Mon Sep 17 00:00:00 2001 From: rinpatch Date: Fri, 27 Apr 2018 17:33:23 +0300 Subject: Fix unit test --- tests/unit/engines/test_acgsou.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/unit/engines/test_acgsou.py b/tests/unit/engines/test_acgsou.py index 2c3e6608f..d115c532a 100644 --- a/tests/unit/engines/test_acgsou.py +++ b/tests/unit/engines/test_acgsou.py @@ -20,14 +20,22 @@ class TestAcgsouEngine(SearxTestCase): self.assertEqual(acgsou.response(resp), []) html = """ + - tablehead + + + + + + + + - + +
发布时间分类资源名称大小种子下载完成发布者/联盟
date testcategory @@ -51,7 +59,9 @@ class TestAcgsouEngine(SearxTestCase): user
+ """ resp = mock.Mock(text=html) -- cgit v1.2.3 From a79c676f2766c00122695fe74ad42ff89cfdcd07 Mon Sep 17 00:00:00 2001 From: rinpatch Date: Fri, 27 Apr 2018 17:38:52 +0300 Subject: Remove Japanese characters --- tests/unit/engines/test_acgsou.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/unit/engines/test_acgsou.py b/tests/unit/engines/test_acgsou.py index d115c532a..c3ea48057 100644 --- a/tests/unit/engines/test_acgsou.py +++ b/tests/unit/engines/test_acgsou.py @@ -24,14 +24,14 @@ class TestAcgsouEngine(SearxTestCase): - - - - - - - - + + + + + + + + -- cgit v1.2.3
发布时间分类资源名称大小种子下载完成发布者/联盟testtesttesttesttesttesttesttest