diff options
Diffstat (limited to 'searx/tests/engines/test_wolframalpha_api.py')
| -rw-r--r-- | searx/tests/engines/test_wolframalpha_api.py | 138 |
1 files changed, 104 insertions, 34 deletions
diff --git a/searx/tests/engines/test_wolframalpha_api.py b/searx/tests/engines/test_wolframalpha_api.py index d9e23182f..98c53f769 100644 --- a/searx/tests/engines/test_wolframalpha_api.py +++ b/searx/tests/engines/test_wolframalpha_api.py @@ -30,32 +30,7 @@ class TestWolframAlphaAPIEngine(SearxTestCase): xml = '''<?xml version='1.0' encoding='UTF-8'?> <queryresult success='false' error='false' /> ''' - - response = mock.Mock(content=xml) - self.assertEqual(wolframalpha_api.response(response), []) - - xml = """<?xml version='1.0' encoding='UTF-8'?> - <queryresult success='false' - error='false' - numpods='0' - datatypes='' - timedout='' - timedoutpods='' - timing='0.241' - parsetiming='0.074' - parsetimedout='false' - recalculate='' - id='' - host='http://www5a.wolframalpha.com' - server='56' - related='' - version='2.6'> - <tips count='1'> - <tip text='Check your spelling, and use English' /> - </tips> - </queryresult> - """ - + # test failure response = mock.Mock(content=xml) self.assertEqual(wolframalpha_api.response(response), []) @@ -145,14 +120,12 @@ class TestWolframAlphaAPIEngine(SearxTestCase): </pod> </queryresult> """ + # test private user area char in response response = mock.Mock(content=xml) results = wolframalpha_api.response(response) self.assertEqual(type(results), list) - # self.assertEqual(len(results), 2) self.assertEqual(len(results), 1) - self.assertIn("i", results[0]['answer']) - # self.assertIn("sqrt(-1) - Wolfram|Alpha", results[1]['title']) - # self.assertIn("http://www.wolframalpha.com/input/?i=sqrt%28-1%29", results[1]['url']) + self.assertIn('i', results[0]['answer']) xml = """<?xml version='1.0' encoding='UTF-8'?> <queryresult success='true' @@ -246,11 +219,108 @@ class TestWolframAlphaAPIEngine(SearxTestCase): </assumptions> </queryresult> """ + # test integral response = mock.Mock(content=xml) results = wolframalpha_api.response(response) self.assertEqual(type(results), list) - # self.assertEqual(len(results), 2) self.assertEqual(len(results), 1) - self.assertIn("log(x)+c", results[0]['answer']) - # self.assertIn("integral 1/x - Wolfram|Alpha", results[1]['title']) - # self.assertIn("http://www.wolframalpha.com/input/?i=integral+1%2Fx", results[1]['url']) + self.assertIn('log(x)+c', results[0]['answer']) + + xml = """<?xml version='1.0' encoding='UTF-8'?> + <queryresult success='true' + error='false' + numpods='4' + datatypes='Solve' + timedout='' + timedoutpods='' + timing='0.883' + parsetiming='0.337' + parsetimedout='false' + recalculate='' + id='MSPa347225h1ea85fgfbgb4000064ff000d25g5df3f' + host='http://www5a.wolframalpha.com' + server='52' + related='http://www5a.wolframalpha.com/api/v2/relatedQueries.jsp?...' + version='2.6'> + <pod title='Input interpretation' + scanner='Identity' + id='Input' + position='100' + error='false' + numsubpods='1'> + <subpod title=''> + <img src='http://www5a.wolframalpha.com/Calculate/MSP/MSP349225h1ea85fgfbgb400005dhd93b9eegg8f32?...' + alt='solve x^2+x = 0' + title='solve x^2+x = 0' + width='157' + height='35' /> + <plaintext>solve x^2+x = 0</plaintext> + </subpod> + </pod> + <pod title='Results' + scanner='Solve' + id='Result' + position='200' + error='false' + numsubpods='2' + primary='true'> + <subpod title=''> + <img src='http://www5a.wolframalpha.com/Calculate/MSP/MSP350225h1ea85fgfbgb400005b1ebcefaha3ac97?...' + alt='x = -1' + title='x = -1' + width='47' + height='18' /> + <plaintext>x = -1</plaintext> + </subpod> + <subpod title=''> + <img src='http://www5a.wolframalpha.com/Calculate/MSP/MSP351225h1ea85fgfbgb4000032fic0ig981hc936?...' + alt='x = 0' + title='x = 0' + width='36' + height='18' /> + <plaintext>x = 0</plaintext> + </subpod> + <states count='1'> + <state name='Step-by-step solution' + input='Result__Step-by-step solution' /> + </states> + </pod> + <pod title='Root plot' + scanner='Solve' + id='RootPlot' + position='300' + error='false' + numsubpods='1'> + <subpod title=''> + <img src='http://www5a.wolframalpha.com/Calculate/MSP/MSP352225h1ea85fgfbgb40000464054c665hc5dee?...' + alt='' + title='' + width='300' + height='181' /> + <plaintext></plaintext> + </subpod> + </pod> + <pod title='Number line' + scanner='Solve' + id='NumberLine' + position='400' + error='false' + numsubpods='1'> + <subpod title=''> + <img src='http://www5a.wolframalpha.com/Calculate/MSP/MSP353225h1ea85fgfbgb400005ab1c8aai366fe46?...' + alt='' + title='' + width='310' + height='36' /> + <plaintext></plaintext> + </subpod> + </pod> + </queryresult> + """ + # test ecuation with multiple answers + response = mock.Mock(content=xml) + results = wolframalpha_api.response(response) + self.assertEqual(type(results), list) + self.assertEqual(len(results), 2) + self.assertIn('x = -1', results[0]['answer']) + self.assertIn('x = 0', results[1]['answer']) |