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/unit/engines/test_acgsou.py') 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/unit/engines/test_acgsou.py') 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/unit/engines/test_acgsou.py') 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 From b7eb05dac68f0488223fd9127e0f5ce4c841e95f Mon Sep 17 00:00:00 2001 From: rinpatch Date: Thu, 3 May 2018 15:20:48 +0300 Subject: Fix unit test url --- tests/unit/engines/test_acgsou.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/unit/engines/test_acgsou.py') diff --git a/tests/unit/engines/test_acgsou.py b/tests/unit/engines/test_acgsou.py index c3ea48057..f97749cc1 100644 --- a/tests/unit/engines/test_acgsou.py +++ b/tests/unit/engines/test_acgsou.py @@ -71,7 +71,7 @@ class TestAcgsouEngine(SearxTestCase): self.assertEqual(len(results), 1) r = results[0] - self.assertEqual(r['url'], 'https://www.acgsou.com/show-torrentid.html') + self.assertEqual(r['url'], 'http://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 059c2ccb9576f8aae36b4e1c0bf6a024d75701ea Mon Sep 17 00:00:00 2001 From: rinpatch Date: Sat, 5 May 2018 23:41:13 +0300 Subject: Fix acgsou encoding error on python2 and add unicode characters to unit testt --- tests/unit/engines/test_acgsou.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'tests/unit/engines/test_acgsou.py') diff --git a/tests/unit/engines/test_acgsou.py b/tests/unit/engines/test_acgsou.py index f97749cc1..c01acf5de 100644 --- a/tests/unit/engines/test_acgsou.py +++ b/tests/unit/engines/test_acgsou.py @@ -1,3 +1,4 @@ +# coding=utf-8 from collections import defaultdict import mock from searx.engines import acgsou @@ -19,7 +20,7 @@ class TestAcgsouEngine(SearxTestCase): resp = mock.Mock(text='') self.assertEqual(acgsou.response(resp), []) - html = """ + html = u"""
发布时间分类资源名称大小种子下载完成发布者/联盟testtesttesttesttesttesttesttest
@@ -37,9 +38,9 @@ class TestAcgsouEngine(SearxTestCase): - +
datetestcategorytestcategory テスト - torrentname + torrentname テスト 1MB @@ -72,6 +73,6 @@ class TestAcgsouEngine(SearxTestCase): r = results[0] self.assertEqual(r['url'], 'http://www.acgsou.com/show-torrentid.html') - self.assertEqual(r['content'], 'Category: "testcategory".') - self.assertEqual(r['title'], 'torrentname') + self.assertEqual(r['content'], u'Category: "testcategory テスト".') + self.assertEqual(r['title'], u'torrentname テスト') self.assertEqual(r['filesize'], 1048576) -- cgit v1.2.3