summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorrinpatch <rinpatch@airmail.cc>2018-04-27 15:36:15 +0300
committerrinpatch <rinpatch@airmail.cc>2018-04-27 15:36:15 +0300
commitdcc9fdb47fd16aa65216846dc52470ada016753c (patch)
tree5c8c63f734ac6308a2fedcdc6d2abbe23b5f9dc2 /tests
parente3bd2670d7d886ba7fb7540781fec130d1e80c9c (diff)
downloadsearxng-dcc9fdb47fd16aa65216846dc52470ada016753c.tar.gz
searxng-dcc9fdb47fd16aa65216846dc52470ada016753c.zip
Added unit test
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/engines/test_acgsou.py67
1 files changed, 67 insertions, 0 deletions
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='<html></html>')
+ self.assertEqual(acgsou.response(resp), [])
+
+ html = """
+<table id="listTable" class="list_style table_fixed">
+ <thead class="tcat">
+ <tr>
+ tablehead
+ </tr>
+ </thead>
+ <tbody class="tbody" id="data_list">
+ <tr class="alt1 ">
+ <td nowrap="nowrap">date</td>
+ <td><a href="category.html">testcategory</a></td>
+ <td style="text-align:left;">
+ <a href="show-torrentid.html" target="_blank">torrentname</a>
+ </td>
+ <td>1MB</td>
+ <td nowrap="nowrap">
+ <span class="bts_1">
+ 29
+ </span>
+ </td>
+ <td nowrap="nowrap">
+ <span class="btl_1">
+ 211
+ </span>
+ </td>
+ <td nowrap="nowrap">
+ <span class="btc_">
+ 168
+ </span>
+ </td>
+ <td><a href="random.html">user</a></td>
+ </tr>
+</table>
+ """
+
+ 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)