| 
									
										
										
										
											2015-01-31 16:16:30 +01: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 | 
					
						
							| 
									
										
										
										
											2015-12-09 01:20:46 +01:00
										 |  |  |         dicto['safesearch'] = 1 | 
					
						
							| 
									
										
										
										
											2016-07-26 00:22:05 +02:00
										 |  |  |         dicto['time_range'] = '' | 
					
						
							| 
									
										
										
										
											2015-01-31 16:16:30 +01:00
										 |  |  |         params = google_images.request(query, dicto) | 
					
						
							| 
									
										
										
										
											2015-02-20 19:03:09 +01:00
										 |  |  |         self.assertIn('url', params) | 
					
						
							|  |  |  |         self.assertIn(query, params['url']) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         dicto['safesearch'] = 0 | 
					
						
							|  |  |  |         params = google_images.request(query, dicto) | 
					
						
							| 
									
										
										
										
											2015-12-09 01:20:46 +01:00
										 |  |  |         self.assertNotIn('safe', params['url']) | 
					
						
							| 
									
										
										
										
											2015-01-31 16:16:30 +01: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, '[]') |