summaryrefslogtreecommitdiff
path: root/searx/tests
diff options
context:
space:
mode:
authorThomas Pointhuber <thomas.pointhuber@gmx.at>2015-02-08 14:12:14 +0100
committerThomas Pointhuber <thomas.pointhuber@gmx.at>2015-02-08 14:12:14 +0100
commit04f7118d0a0693906ef57fa83f01d29eb366a45e (patch)
tree1328e80350a8861ddd8c630bb09bafa8b849bd38 /searx/tests
parent7c075aa73197030d01b210054488ce99ec861d70 (diff)
[enh] add gigablast engine
Diffstat (limited to 'searx/tests')
-rw-r--r--searx/tests/engines/test_gigablast.py57
-rw-r--r--searx/tests/test_engines.py1
2 files changed, 58 insertions, 0 deletions
diff --git a/searx/tests/engines/test_gigablast.py b/searx/tests/engines/test_gigablast.py
new file mode 100644
index 000000000..38264913f
--- /dev/null
+++ b/searx/tests/engines/test_gigablast.py
@@ -0,0 +1,57 @@
+from collections import defaultdict
+import mock
+from searx.engines import gigablast
+from searx.testing import SearxTestCase
+
+
+class TestGigablastEngine(SearxTestCase):
+
+ def test_request(self):
+ query = 'test_query'
+ dicto = defaultdict(dict)
+ dicto['pageno'] = 0
+ params = gigablast.request(query, dicto)
+ self.assertTrue('url' in params)
+ self.assertTrue(query in params['url'])
+ self.assertTrue('gigablast.com' in params['url'])
+
+ def test_response(self):
+ self.assertRaises(AttributeError, gigablast.response, None)
+ self.assertRaises(AttributeError, gigablast.response, [])
+ self.assertRaises(AttributeError, gigablast.response, '')
+ self.assertRaises(AttributeError, gigablast.response, '[]')
+
+ response = mock.Mock(content='<response></response>')
+ self.assertEqual(gigablast.response(response), [])
+
+ response = mock.Mock(content='<response></response>')
+ self.assertEqual(gigablast.response(response), [])
+
+ xml = """<?xml version="1.0" encoding="UTF-8" ?>
+ <response>
+ <hits>5941888</hits>
+ <moreResultsFollow>1</moreResultsFollow>
+ <result>
+ <title><![CDATA[This should be the title]]></title>
+ <sum><![CDATA[This should be the content.]]></sum>
+ <url><![CDATA[http://this.should.be.the.link/]]></url>
+ <size>90.5</size>
+ <docId>145414002633</docId>
+ <siteId>2660021087</siteId>
+ <domainId>2660021087</domainId>
+ <spidered>1320519373</spidered>
+ <indexed>1320519373</indexed>
+ <pubdate>4294967295</pubdate>
+ <isModDate>0</isModDate>
+ <language><![CDATA[English]]></language>
+ <charset><![CDATA[UTF-8]]></charset>
+ </result>
+ </response>
+ """
+ response = mock.Mock(content=xml)
+ results = gigablast.response(response)
+ self.assertEqual(type(results), list)
+ self.assertEqual(len(results), 1)
+ self.assertEqual(results[0]['title'], 'This should be the title')
+ self.assertEqual(results[0]['url'], 'http://this.should.be.the.link/')
+ self.assertEqual(results[0]['content'], 'This should be the content.')
diff --git a/searx/tests/test_engines.py b/searx/tests/test_engines.py
index ff8185b1e..30f2d0912 100644
--- a/searx/tests/test_engines.py
+++ b/searx/tests/test_engines.py
@@ -9,6 +9,7 @@ from searx.tests.engines.test_digg import * # noqa
from searx.tests.engines.test_dummy import * # noqa
from searx.tests.engines.test_flickr import * # noqa
from searx.tests.engines.test_flickr_noapi import * # noqa
+from searx.tests.engines.test_gigablast import * # noqa
from searx.tests.engines.test_github import * # noqa
from searx.tests.engines.test_www1x import * # noqa
from searx.tests.engines.test_google_images import * # noqa