diff options
author | Thomas Pointhuber <thomas.pointhuber@gmx.at> | 2015-02-08 14:49:46 +0100 |
---|---|---|
committer | Thomas Pointhuber <thomas.pointhuber@gmx.at> | 2015-02-08 14:49:46 +0100 |
commit | dd4686a3886458f600427aba0ed7b9666b3644db (patch) | |
tree | 8bd6d19dc101dda652525623627af2a8a5c86205 /searx/tests | |
parent | 04f7118d0a0693906ef57fa83f01d29eb366a45e (diff) | |
download | searxng-dd4686a3886458f600427aba0ed7b9666b3644db.tar.gz searxng-dd4686a3886458f600427aba0ed7b9666b3644db.zip |
[enh] add blekko_images engine
Diffstat (limited to 'searx/tests')
-rw-r--r-- | searx/tests/engines/test_blekko_images.py | 65 | ||||
-rw-r--r-- | searx/tests/test_engines.py | 1 |
2 files changed, 66 insertions, 0 deletions
diff --git a/searx/tests/engines/test_blekko_images.py b/searx/tests/engines/test_blekko_images.py new file mode 100644 index 000000000..6a5388aae --- /dev/null +++ b/searx/tests/engines/test_blekko_images.py @@ -0,0 +1,65 @@ +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 + 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/test_engines.py b/searx/tests/test_engines.py index 30f2d0912..651da6dc2 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_dailymotion import * # noqa from searx.tests.engines.test_deezer import * # noqa |