summaryrefslogtreecommitdiff
path: root/searx/tests
diff options
context:
space:
mode:
Diffstat (limited to 'searx/tests')
-rw-r--r--searx/tests/engines/test_bing_images.py1
-rw-r--r--searx/tests/engines/test_blekko_images.py66
-rw-r--r--searx/tests/engines/test_gigablast.py57
-rw-r--r--searx/tests/engines/test_piratebay.py6
-rw-r--r--searx/tests/test_engines.py2
5 files changed, 129 insertions, 3 deletions
diff --git a/searx/tests/engines/test_bing_images.py b/searx/tests/engines/test_bing_images.py
index 59c134623..a1d96b06e 100644
--- a/searx/tests/engines/test_bing_images.py
+++ b/searx/tests/engines/test_bing_images.py
@@ -12,6 +12,7 @@ class TestBingImagesEngine(SearxTestCase):
dicto = defaultdict(dict)
dicto['pageno'] = 1
dicto['language'] = 'fr_FR'
+ dicto['safesearch'] = 1
params = bing_images.request(query, dicto)
self.assertTrue('url' in params)
self.assertTrue(query in params['url'])
diff --git a/searx/tests/engines/test_blekko_images.py b/searx/tests/engines/test_blekko_images.py
new file mode 100644
index 000000000..793fadbad
--- /dev/null
+++ b/searx/tests/engines/test_blekko_images.py
@@ -0,0 +1,66 @@
+from collections import defaultdict
+import mock
+from searx.engines import blekko_images
+from searx.testing import SearxTestCase
+
+
+class TestBlekkoImagesEngine(SearxTestCase):
+
+ def test_request(self):
+ query = 'test_query'
+ dicto = defaultdict(dict)
+ dicto['pageno'] = 0
+ dicto['safesearch'] = 1
+ params = blekko_images.request(query, dicto)
+ self.assertTrue('url' in params)
+ self.assertTrue(query in params['url'])
+ self.assertTrue('blekko.com' in params['url'])
+
+ def test_response(self):
+ self.assertRaises(AttributeError, blekko_images.response, None)
+ self.assertRaises(AttributeError, blekko_images.response, [])
+ self.assertRaises(AttributeError, blekko_images.response, '')
+ self.assertRaises(AttributeError, blekko_images.response, '[]')
+
+ response = mock.Mock(text='[]')
+ self.assertEqual(blekko_images.response(response), [])
+
+ json = """
+ [
+ {
+ "c": 1,
+ "page_url": "http://result_url.html",
+ "title": "Photo title",
+ "tn_url": "http://ts1.mm.bing.net/th?id=HN.608050619474382748&pid=15.1",
+ "url": "http://result_image.jpg"
+ },
+ {
+ "c": 2,
+ "page_url": "http://companyorange.simpsite.nl/OSM",
+ "title": "OSM",
+ "tn_url": "http://ts2.mm.bing.net/th?id=HN.608048068264919461&pid=15.1",
+ "url": "http://simpsite.nl/userdata2/58985/Home/OSM.bmp"
+ },
+ {
+ "c": 3,
+ "page_url": "http://invincible.webklik.nl/page/osm",
+ "title": "OSM",
+ "tn_url": "http://ts1.mm.bing.net/th?id=HN.608024514657649476&pid=15.1",
+ "url": "http://www.webklik.nl/user_files/2009_09/65324/osm.gif"
+ },
+ {
+ "c": 4,
+ "page_url": "http://www.offshorenorway.no/event/companyDetail/id/12492",
+ "title": "Go to OSM Offshore AS homepage",
+ "tn_url": "http://ts2.mm.bing.net/th?id=HN.608054265899847285&pid=15.1",
+ "url": "http://www.offshorenorway.no/firmalogo/OSM-logo.png"
+ }
+ ]
+ """
+ response = mock.Mock(text=json)
+ results = blekko_images.response(response)
+ self.assertEqual(type(results), list)
+ self.assertEqual(len(results), 4)
+ self.assertEqual(results[0]['title'], 'Photo title')
+ self.assertEqual(results[0]['url'], 'http://result_url.html')
+ self.assertEqual(results[0]['img_src'], 'http://result_image.jpg')
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/engines/test_piratebay.py b/searx/tests/engines/test_piratebay.py
index 7207c408a..17bc3a526 100644
--- a/searx/tests/engines/test_piratebay.py
+++ b/searx/tests/engines/test_piratebay.py
@@ -15,7 +15,7 @@ class TestPiratebayEngine(SearxTestCase):
params = piratebay.request(query, dicto)
self.assertIn('url', params)
self.assertIn(query, params['url'])
- self.assertIn('piratebay.cr', params['url'])
+ self.assertIn('piratebay.se', params['url'])
self.assertIn('0', params['url'])
dicto['category'] = 'music'
@@ -72,7 +72,7 @@ class TestPiratebayEngine(SearxTestCase):
self.assertEqual(type(results), list)
self.assertEqual(len(results), 1)
self.assertEqual(results[0]['title'], 'This is the title')
- self.assertEqual(results[0]['url'], 'https://thepiratebay.cr/this.is.the.link')
+ self.assertEqual(results[0]['url'], 'https://thepiratebay.se/this.is.the.link')
self.assertEqual(results[0]['content'], 'This is the content and should be OK')
self.assertEqual(results[0]['seed'], 13)
self.assertEqual(results[0]['leech'], 334)
@@ -120,7 +120,7 @@ class TestPiratebayEngine(SearxTestCase):
self.assertEqual(type(results), list)
self.assertEqual(len(results), 1)
self.assertEqual(results[0]['title'], 'This is the title')
- self.assertEqual(results[0]['url'], 'https://thepiratebay.cr/this.is.the.link')
+ self.assertEqual(results[0]['url'], 'https://thepiratebay.se/this.is.the.link')
self.assertEqual(results[0]['content'], 'This is the content and should be OK')
self.assertEqual(results[0]['seed'], 0)
self.assertEqual(results[0]['leech'], 0)
diff --git a/searx/tests/test_engines.py b/searx/tests/test_engines.py
index 81296c304..9b1c12cb1 100644
--- a/searx/tests/test_engines.py
+++ b/searx/tests/test_engines.py
@@ -1,6 +1,7 @@
from searx.tests.engines.test_bing import * # noqa
from searx.tests.engines.test_bing_images import * # noqa
from searx.tests.engines.test_bing_news import * # noqa
+from searx.tests.engines.test_blekko_images import * # noqa
from searx.tests.engines.test_btdigg import * # noqa
from searx.tests.engines.test_currency_convert import * # noqa
from searx.tests.engines.test_dailymotion import * # noqa
@@ -13,6 +14,7 @@ from searx.tests.engines.test_dummy import * # noqa
from searx.tests.engines.test_faroo 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_google import * # noqa
from searx.tests.engines.test_google_images import * # noqa