logo

searx

My custom branche(s) on searx, a meta-search engine git clone https://anongit.hacktivis.me/git/searx.git/

test_google_images.py (942B)


  1. from collections import defaultdict
  2. import mock
  3. from searx.engines import google_images
  4. from searx.testing import SearxTestCase
  5. class TestGoogleImagesEngine(SearxTestCase):
  6. def test_request(self):
  7. query = 'test_query'
  8. dicto = defaultdict(dict)
  9. dicto['pageno'] = 1
  10. dicto['safesearch'] = 1
  11. dicto['time_range'] = ''
  12. params = google_images.request(query, dicto)
  13. self.assertIn('url', params)
  14. self.assertIn(query, params['url'])
  15. dicto['safesearch'] = 0
  16. params = google_images.request(query, dicto)
  17. self.assertNotIn('safe', params['url'])
  18. def test_response(self):
  19. self.assertRaises(AttributeError, google_images.response, None)
  20. self.assertRaises(AttributeError, google_images.response, [])
  21. self.assertRaises(AttributeError, google_images.response, '')
  22. self.assertRaises(AttributeError, google_images.response, '[]')