diff options
| author | a01200356 <a01200356@itesm.mx> | 2016-01-02 00:41:14 -0600 |
|---|---|---|
| committer | a01200356 <a01200356@itesm.mx> | 2016-01-02 00:41:14 -0600 |
| commit | e9d35c1309f05a0b214fb323049909ee7ec62ab8 (patch) | |
| tree | c9b8cf6cdb951b66c86c9c55c328456e59cb4042 /searx/tests/engines/test_wolframalpha_api.py | |
| parent | 0871c7ca85cd19a2fa0971c7db28516a74255d5d (diff) | |
update tests for wolframalpha
Diffstat (limited to 'searx/tests/engines/test_wolframalpha_api.py')
| -rw-r--r-- | searx/tests/engines/test_wolframalpha_api.py | 358 |
1 files changed, 160 insertions, 198 deletions
diff --git a/searx/tests/engines/test_wolframalpha_api.py b/searx/tests/engines/test_wolframalpha_api.py index d295cea7a..a4a4184c5 100644 --- a/searx/tests/engines/test_wolframalpha_api.py +++ b/searx/tests/engines/test_wolframalpha_api.py @@ -60,233 +60,195 @@ class TestWolframAlphaAPIEngine(SearxTestCase): self.assertEqual(wolframalpha_api.response(response), []) xml = """<?xml version='1.0' encoding='UTF-8'?> + <queryresult success='true' + error='false' + numpods='6' + datatypes='' + timedout='' + timedoutpods='' + timing='0.684' + parsetiming='0.138' + parsetimedout='false' + recalculate='' + id='MSPa416020a7966dachc463600000f9c66cc21444cfg' + host='http://www3.wolframalpha.com' + server='6' + related='http://www3.wolframalpha.com/api/v2/relatedQueries.jsp?...' + version='2.6'> + <pod title='Input' + scanner='Identity' + id='Input' + position='100' + error='false' + numsubpods='1'> + <subpod title=''> + <plaintext>sqrt(-1)</plaintext> + </subpod> + </pod> + <pod title='Result' + scanner='Simplification' + id='Result' + position='200' + error='false' + numsubpods='1' + primary='true'> + <subpod title=''> + <plaintext></plaintext> + </subpod> + <states count='1'> + <state name='Step-by-step solution' + input='Result__Step-by-step solution' /> + </states> + </pod> + <pod title='Polar coordinates' + scanner='Numeric' + id='PolarCoordinates' + position='300' + error='false' + numsubpods='1'> + <subpod title=''> + <plaintext>r1 (radius), θ90° (angle)</plaintext> + </subpod> + </pod> + <pod title='Position in the complex plane' + scanner='Numeric' + id='PositionInTheComplexPlane' + position='400' + error='false' + numsubpods='1'> + <subpod title=''> + <plaintext></plaintext> + </subpod> + </pod> + <pod title='All 2nd roots of -1' + scanner='RootsOfUnity' + id='' + position='500' + error='false' + numsubpods='2'> + <subpod title=''> + <plaintext> (principal root)</plaintext> + </subpod> + <subpod title=''> + <plaintext>-</plaintext> + </subpod> + </pod> + <pod title='Plot of all roots in the complex plane' + scanner='RootsOfUnity' + id='PlotOfAllRootsInTheComplexPlane' + position='600' + error='false' + numsubpods='1'> + <subpod title=''> + <plaintext></plaintext> + </subpod> + </pod> + </queryresult> + """ + response = mock.Mock(content=xml) + results = wolframalpha_api.response(response) + self.assertEqual(type(results), list) + self.assertEqual(len(results), 2) + 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']) + + xml = """<?xml version='1.0' encoding='UTF-8'?> <queryresult success='true' error='false' - numpods='6' + numpods='2' datatypes='' timedout='' timedoutpods='' - timing='0.826' - parsetiming='0.17' + timing='1.286' + parsetiming='0.255' parsetimedout='false' recalculate='' - id='MSPa9721hfe10fii5idac02000029c3a6f09608410h' - host='http://www4c.wolframalpha.com' - server='53' - related='http://www4c.wolframalpha.com/api/v2/relatedQueries.jsp?id=MSPa9731h927ig0h6b1&s=53' + id='MSPa195222ad740ede5214h30000480ca61h003d3gd6' + host='http://www3.wolframalpha.com' + server='20' + related='http://www3.wolframalpha.com/api/v2/relatedQueries.jsp?id=...' version='2.6'> - <pod title='Input' - scanner='Identity' - id='Input' + <pod title='Indefinite integral' + scanner='Integral' + id='IndefiniteIntegral' position='100' error='false' - numsubpods='1'> - <subpod title=''> - <img src='http://www4c.wolframalpha.com/Calculate/MSP/MSP974111ig68hc?MSPStoreType=image/gif&s=53' - alt='sqrt(-1)' - title='sqrt(-1)' - width='36' - height='20' /> - <plaintext>sqrt(-1)</plaintext> - </subpod> - </pod> - <pod title='Result' - scanner='Simplification' - id='Result' - position='200' - error='false' numsubpods='1' primary='true'> <subpod title=''> - <img src='http://www4c.wolframalpha.com/Calculate/MSP/MSP9751hfe101fc27?MSPStoreType=image/gif&s=53' - alt='i' - title='i' - width='5' - height='18' /> - <plaintext>i</plaintext> + <plaintext>∫1/xxlog(x)+constant</plaintext> </subpod> <states count='1'> <state name='Step-by-step solution' - input='Result__Step-by-step solution' /> + input='IndefiniteIntegral__Step-by-step solution' /> </states> + <infos count='1'> + <info text='log(x) is the natural logarithm'> + <link url='http://reference.wolfram.com/mathematica/ref/Log.html' + text='Documentation' + title='Mathematica' /> + <link url='http://functions.wolfram.com/ElementaryFunctions/Log' + text='Properties' + title='Wolfram Functions Site' /> + <link url='http://mathworld.wolfram.com/NaturalLogarithm.html' + text='Definition' + title='MathWorld' /> + </info> + </infos> </pod> - <pod title='Polar coordinates' - scanner='Numeric' - id='PolarCoordinates' - position='300' - error='false' - numsubpods='1'> - <subpod title=''> - <img src='http://www4c.wolframalpha.com/Calculate/MSP/MSP97600003i83?MSPStoreType=image/gif&s=53' - alt='r = 1 (radius), theta = 90° (angle)' - title='r = 1 (radius), theta = 90° (angle)' - width='209' - height='18' /> - <plaintext>r = 1 (radius), theta = 90° (angle)</plaintext> - </subpod> - </pod> - <pod title='Position in the complex plane' - scanner='Numeric' - id='PositionInTheComplexPlane' - position='400' - error='false' - numsubpods='1'> - <subpod title=''> - <img src='http://www4c.wolframalpha.com/Calculate/MSP/MSP9771e10ficg4g?MSPStoreType=image/gif&s=53' - alt='' - title='' - width='200' - height='185' /> - <plaintext></plaintext> - </subpod> - </pod> - <pod title='All 2nd roots of -1' - scanner='RootsOfUnity' - id='' - position='500' + <pod title='Plots of the integral' + scanner='Integral' + id='Plot' + position='200' error='false' numsubpods='2'> <subpod title=''> - <img src='http://www4c.wolframalpha.com/Calculate/MSP/MSP9781hfe10fii?MSPStoreType=image/gif&s=53' - alt='i (principal root)' - title='i (principal root)' - width='94' - height='18' /> - <plaintext>i (principal root)</plaintext> + <plaintext></plaintext> + <states count='1'> + <statelist count='2' + value='Complex-valued plot' + delimiters=''> + <state name='Complex-valued plot' + input='Plot__1_Complex-valued plot' /> + <state name='Real-valued plot' + input='Plot__1_Real-valued plot' /> + </statelist> + </states> </subpod> <subpod title=''> - <img src='http://www4c.wolframalpha.com/Calculate/MSP/MSP9791hfe16f2eh1?MSPStoreType=image/gif&s=53' - alt='-i' - title='-i' - width='16' - height='18' /> - <plaintext>-i</plaintext> - </subpod> - </pod> - <pod title='Plot of all roots in the complex plane' - scanner='RootsOfUnity' - id='PlotOfAllRootsInTheComplexPlane' - position='600' - error='false' - numsubpods='1'> - <subpod title=''> - <img src='http://www4c.wolframalpha.com/Calculate/MSP/MSP9801h0fi192f9?MSPStoreType=image/gif&s=53' - alt='' - title='' - width='200' - height='185' /> <plaintext></plaintext> + <states count='1'> + <statelist count='2' + value='Complex-valued plot' + delimiters=''> + <state name='Complex-valued plot' + input='Plot__2_Complex-valued plot' /> + <state name='Real-valued plot' + input='Plot__2_Real-valued plot' /> + </statelist> + </states> </subpod> </pod> + <assumptions count='1'> + <assumption type='Clash' + word='integral' + template='Assuming "${word}" is ${desc1}. Use as ${desc2} instead' + count='2'> + <value name='IntegralsWord' + desc='an integral' + input='*C.integral-_*IntegralsWord-' /> + <value name='MathematicalFunctionIdentityPropertyClass' + desc='a function property' + input='*C.integral-_*MathematicalFunctionIdentityPropertyClass-' /> + </assumption> + </assumptions> </queryresult> """ response = mock.Mock(content=xml) results = wolframalpha_api.response(response) self.assertEqual(type(results), list) - self.assertEqual(len(results), 1) - self.assertIn("i", results[0]['answer']) - - xml = """<?xml version='1.0' encoding='UTF-8'?> - <queryresult success='true' - error='false' - numpods='2' - datatypes='' - timedout='Integral' - timedoutpods='' - timing='1.245' - parsetiming='0.194' - parsetimedout='false' - recalculate='http://www4b.wolframalpha.com/api/v2/recalc.jsp?id=MSPa77651gf1a1hie0ii051ea0e1c&s=3' - id='MSPa77661gf1a1hie5c9d9a600003baifafc1211daef' - host='http://www4b.wolframalpha.com' - server='3' - related='http://www4b.wolframalpha.com/api/v2/relatedQueries.jsp?id=MSPa77671gf1a1hie5c5hc2&s=3' - version='2.6'> - <pod title='Indefinite integral' - scanner='Integral' - id='IndefiniteIntegral' - position='100' - error='false' - numsubpods='1' - primary='true'> - <subpod title=''> - <img src='http://www4b.wolframalpha.com/Calculate/MSP/MSP776814b9492i9a7gb16?MSPStoreType=image/gif&s=3' - alt=' integral 1/x dx = log(x)+constant' - title=' integral 1/x dx = log(x)+constant' - width='182' - height='36' /> - <plaintext> integral 1/x dx = log(x)+constant</plaintext> - </subpod> - <states count='1'> - <state name='Step-by-step solution' - input='IndefiniteIntegral__Step-by-step solution' /> - </states> - <infos count='1'> - <info text='log(x) is the natural logarithm'> - <img src='http://www4b.wolframalpha.com/Calculate/MSP/MSP77691g23eg440g89db?MSPStoreType=image/gif&s=3' - alt='log(x) is the natural logarithm' - title='log(x) is the natural logarithm' - width='198' - height='18' /> - <link url='http://reference.wolfram.com/mathematica/ref/Log.html' - text='Documentation' - title='Mathematica' /> - <link url='http://functions.wolfram.com/ElementaryFunctions/Log' - text='Properties' - title='Wolfram Functions Site' /> - <link url='http://mathworld.wolfram.com/NaturalLogarithm.html' - text='Definition' - title='MathWorld' /> - </info> - </infos> - </pod> - <pod title='Plots of the integral' - scanner='Integral' - id='Plot' - position='200' - error='false' - numsubpods='2'> - <subpod title=''> - <img src='http://www4b.wolframalpha.com/Calculate/MSP/MSP77701gf1a9d2eb630g9?MSPStoreType=image/gif&s=3' - alt='' - title='' - width='334' - height='128' /> - <plaintext></plaintext> - <states count='1'> - <statelist count='2' - value='Complex-valued plot' - delimiters=''> - <state name='Complex-valued plot' - input='Plot__1_Complex-valued plot' /> - <state name='Real-valued plot' - input='Plot__1_Real-valued plot' /> - </statelist> - </states> - </subpod> - <subpod title=''> - <img src='http://www4b.wolframalpha.com/Calculate/MSP/MSP77711gf1ai29a34b0ab?MSPStoreType=image/gif&s=3' - alt='' - title='' - width='334' - height='133' /> - <plaintext></plaintext> - <states count='1'> - <statelist count='2' - value='Complex-valued plot' - delimiters=''> - <state name='Complex-valued plot' - input='Plot__2_Complex-valued plot' /> - <state name='Real-valued plot' - input='Plot__2_Real-valued plot' /> - </statelist> - </states> - </subpod> - </pod> - </queryresult> - """ - response = mock.Mock(content=xml) - results = wolframalpha_api.response(response) - self.assertEqual(type(results), list) - self.assertEqual(len(results), 1) + self.assertEqual(len(results), 2) 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']) |