Add test case in wolframalpha_noapi
[fix] Display multiple answers in wolframalpha_api
This commit is contained in:
		
							parent
							
								
									19d025f0e7
								
							
						
					
					
						commit
						d05c676ed5
					
				| @ -52,10 +52,11 @@ def response(resp): | |||||||
|     if search_results.xpath(failure_xpath): |     if search_results.xpath(failure_xpath): | ||||||
|         return [] |         return [] | ||||||
| 
 | 
 | ||||||
|     # parse answer |     # parse answers | ||||||
|     answer = search_results.xpath(answer_xpath) |     answers = search_results.xpath(answer_xpath) | ||||||
|     if answer: |     if answers: | ||||||
|         answer = replace_pua_chars(answer[0].text) |         for answer in answers: | ||||||
|  |             answer = replace_pua_chars(answer.text) | ||||||
| 
 | 
 | ||||||
|             results.append({'answer': answer}) |             results.append({'answer': answer}) | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -305,7 +305,7 @@ engines: | |||||||
|     # You can use the engine using the official stable API, but you need an API key |     # You can use the engine using the official stable API, but you need an API key | ||||||
|     # See : http://products.wolframalpha.com/api/ |     # See : http://products.wolframalpha.com/api/ | ||||||
|     #    engine : wolframalpha_api |     #    engine : wolframalpha_api | ||||||
|     #    api_key: 'apikey' # required! |     #    api_key: '5952JX-X52L3VKWT8' # required! | ||||||
|     engine : wolframalpha_noapi |     engine : wolframalpha_noapi | ||||||
|     timeout: 6.0 |     timeout: 6.0 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -22,8 +22,27 @@ class TestWolframAlphaNoAPIEngine(SearxTestCase): | |||||||
|         self.assertRaises(AttributeError, wolframalpha_noapi.response, '') |         self.assertRaises(AttributeError, wolframalpha_noapi.response, '') | ||||||
|         self.assertRaises(AttributeError, wolframalpha_noapi.response, '[]') |         self.assertRaises(AttributeError, wolframalpha_noapi.response, '[]') | ||||||
| 
 | 
 | ||||||
|         # response = mock.Mock(text='<html></html>') | 		html = """ | ||||||
|         # self.assertEqual(wolframalpha_noapi.response(response), []) |     	<!DOCTYPE html> | ||||||
|  | 			<title> Parangaricutirimícuaro - Wolfram|Alpha</title> | ||||||
|  | 			<meta charset="utf-8" /> | ||||||
|  | 			<body> | ||||||
|  | 				<div id="closest"> | ||||||
|  | 					<p class="pfail">Wolfram|Alpha doesn't know how to interpret your input.</p> | ||||||
|  | 					<div id="dtips"> | ||||||
|  | 						<div class="tip"> | ||||||
|  | 							<span class="tip-title">Tip: </span> | ||||||
|  | 								Check your spelling, and use English | ||||||
|  | 							<span class="tip-extra"></span> | ||||||
|  | 						</div> | ||||||
|  | 					</div> | ||||||
|  | 				</div> | ||||||
|  | 			</body> | ||||||
|  | 		</html> | ||||||
|  |         """ | ||||||
|  | 
 | ||||||
|  |         response = mock.Mock(text=html) | ||||||
|  |         self.assertEqual(wolframalpha_noapi.response(response), []) | ||||||
| 
 | 
 | ||||||
|         html = """ |         html = """ | ||||||
|         <!DOCTYPE html> |         <!DOCTYPE html> | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user