searxngRebrandZaclys/tests/unit/engines/test_google_images.py

28 lines
942 B
Python
Raw Normal View History

2015-01-31 15:16:30 +00:00
from collections import defaultdict
import mock
from searx.engines import google_images
from searx.testing import SearxTestCase
class TestGoogleImagesEngine(SearxTestCase):
def test_request(self):
query = 'test_query'
dicto = defaultdict(dict)
dicto['pageno'] = 1
dicto['safesearch'] = 1
2016-07-25 22:22:05 +00:00
dicto['time_range'] = ''
2015-01-31 15:16:30 +00:00
params = google_images.request(query, dicto)
2015-02-20 18:03:09 +00:00
self.assertIn('url', params)
self.assertIn(query, params['url'])
dicto['safesearch'] = 0
params = google_images.request(query, dicto)
self.assertNotIn('safe', params['url'])
2015-01-31 15:16:30 +00:00
def test_response(self):
self.assertRaises(AttributeError, google_images.response, None)
self.assertRaises(AttributeError, google_images.response, [])
self.assertRaises(AttributeError, google_images.response, '')
self.assertRaises(AttributeError, google_images.response, '[]')