|
@@ -60,233 +60,195 @@ class TestWolframAlphaAPIEngine(SearxTestCase):
|
60
|
60
|
self.assertEqual(wolframalpha_api.response(response), [])
|
61
|
61
|
|
62
|
62
|
xml = """<?xml version='1.0' encoding='UTF-8'?>
|
|
63
|
+ <queryresult success='true'
|
|
64
|
+ error='false'
|
|
65
|
+ numpods='6'
|
|
66
|
+ datatypes=''
|
|
67
|
+ timedout=''
|
|
68
|
+ timedoutpods=''
|
|
69
|
+ timing='0.684'
|
|
70
|
+ parsetiming='0.138'
|
|
71
|
+ parsetimedout='false'
|
|
72
|
+ recalculate=''
|
|
73
|
+ id='MSPa416020a7966dachc463600000f9c66cc21444cfg'
|
|
74
|
+ host='http://www3.wolframalpha.com'
|
|
75
|
+ server='6'
|
|
76
|
+ related='http://www3.wolframalpha.com/api/v2/relatedQueries.jsp?...'
|
|
77
|
+ version='2.6'>
|
|
78
|
+ <pod title='Input'
|
|
79
|
+ scanner='Identity'
|
|
80
|
+ id='Input'
|
|
81
|
+ position='100'
|
|
82
|
+ error='false'
|
|
83
|
+ numsubpods='1'>
|
|
84
|
+ <subpod title=''>
|
|
85
|
+ <plaintext>sqrt(-1)</plaintext>
|
|
86
|
+ </subpod>
|
|
87
|
+ </pod>
|
|
88
|
+ <pod title='Result'
|
|
89
|
+ scanner='Simplification'
|
|
90
|
+ id='Result'
|
|
91
|
+ position='200'
|
|
92
|
+ error='false'
|
|
93
|
+ numsubpods='1'
|
|
94
|
+ primary='true'>
|
|
95
|
+ <subpod title=''>
|
|
96
|
+ <plaintext></plaintext>
|
|
97
|
+ </subpod>
|
|
98
|
+ <states count='1'>
|
|
99
|
+ <state name='Step-by-step solution'
|
|
100
|
+ input='Result__Step-by-step solution' />
|
|
101
|
+ </states>
|
|
102
|
+ </pod>
|
|
103
|
+ <pod title='Polar coordinates'
|
|
104
|
+ scanner='Numeric'
|
|
105
|
+ id='PolarCoordinates'
|
|
106
|
+ position='300'
|
|
107
|
+ error='false'
|
|
108
|
+ numsubpods='1'>
|
|
109
|
+ <subpod title=''>
|
|
110
|
+ <plaintext>r1 (radius), θ90° (angle)</plaintext>
|
|
111
|
+ </subpod>
|
|
112
|
+ </pod>
|
|
113
|
+ <pod title='Position in the complex plane'
|
|
114
|
+ scanner='Numeric'
|
|
115
|
+ id='PositionInTheComplexPlane'
|
|
116
|
+ position='400'
|
|
117
|
+ error='false'
|
|
118
|
+ numsubpods='1'>
|
|
119
|
+ <subpod title=''>
|
|
120
|
+ <plaintext></plaintext>
|
|
121
|
+ </subpod>
|
|
122
|
+ </pod>
|
|
123
|
+ <pod title='All 2nd roots of -1'
|
|
124
|
+ scanner='RootsOfUnity'
|
|
125
|
+ id=''
|
|
126
|
+ position='500'
|
|
127
|
+ error='false'
|
|
128
|
+ numsubpods='2'>
|
|
129
|
+ <subpod title=''>
|
|
130
|
+ <plaintext> (principal root)</plaintext>
|
|
131
|
+ </subpod>
|
|
132
|
+ <subpod title=''>
|
|
133
|
+ <plaintext>-</plaintext>
|
|
134
|
+ </subpod>
|
|
135
|
+ </pod>
|
|
136
|
+ <pod title='Plot of all roots in the complex plane'
|
|
137
|
+ scanner='RootsOfUnity'
|
|
138
|
+ id='PlotOfAllRootsInTheComplexPlane'
|
|
139
|
+ position='600'
|
|
140
|
+ error='false'
|
|
141
|
+ numsubpods='1'>
|
|
142
|
+ <subpod title=''>
|
|
143
|
+ <plaintext></plaintext>
|
|
144
|
+ </subpod>
|
|
145
|
+ </pod>
|
|
146
|
+ </queryresult>
|
|
147
|
+ """
|
|
148
|
+ response = mock.Mock(content=xml)
|
|
149
|
+ results = wolframalpha_api.response(response)
|
|
150
|
+ self.assertEqual(type(results), list)
|
|
151
|
+ self.assertEqual(len(results), 2)
|
|
152
|
+ self.assertIn("i", results[0]['answer'])
|
|
153
|
+ # self.assertIn("sqrt(-1) - Wolfram|Alpha", results[1]['title'])
|
|
154
|
+ # self.assertIn("http://www.wolframalpha.com/input/?i=sqrt%28-1%29", results[1]['url'])
|
|
155
|
+
|
|
156
|
+ xml = """<?xml version='1.0' encoding='UTF-8'?>
|
63
|
157
|
<queryresult success='true'
|
64
|
158
|
error='false'
|
65
|
|
- numpods='6'
|
|
159
|
+ numpods='2'
|
66
|
160
|
datatypes=''
|
67
|
161
|
timedout=''
|
68
|
162
|
timedoutpods=''
|
69
|
|
- timing='0.826'
|
70
|
|
- parsetiming='0.17'
|
|
163
|
+ timing='1.286'
|
|
164
|
+ parsetiming='0.255'
|
71
|
165
|
parsetimedout='false'
|
72
|
166
|
recalculate=''
|
73
|
|
- id='MSPa9721hfe10fii5idac02000029c3a6f09608410h'
|
74
|
|
- host='http://www4c.wolframalpha.com'
|
75
|
|
- server='53'
|
76
|
|
- related='http://www4c.wolframalpha.com/api/v2/relatedQueries.jsp?id=MSPa9731h927ig0h6b1&s=53'
|
|
167
|
+ id='MSPa195222ad740ede5214h30000480ca61h003d3gd6'
|
|
168
|
+ host='http://www3.wolframalpha.com'
|
|
169
|
+ server='20'
|
|
170
|
+ related='http://www3.wolframalpha.com/api/v2/relatedQueries.jsp?id=...'
|
77
|
171
|
version='2.6'>
|
78
|
|
- <pod title='Input'
|
79
|
|
- scanner='Identity'
|
80
|
|
- id='Input'
|
|
172
|
+ <pod title='Indefinite integral'
|
|
173
|
+ scanner='Integral'
|
|
174
|
+ id='IndefiniteIntegral'
|
81
|
175
|
position='100'
|
82
|
176
|
error='false'
|
83
|
|
- numsubpods='1'>
|
84
|
|
- <subpod title=''>
|
85
|
|
- <img src='http://www4c.wolframalpha.com/Calculate/MSP/MSP974111ig68hc?MSPStoreType=image/gif&s=53'
|
86
|
|
- alt='sqrt(-1)'
|
87
|
|
- title='sqrt(-1)'
|
88
|
|
- width='36'
|
89
|
|
- height='20' />
|
90
|
|
- <plaintext>sqrt(-1)</plaintext>
|
91
|
|
- </subpod>
|
92
|
|
- </pod>
|
93
|
|
- <pod title='Result'
|
94
|
|
- scanner='Simplification'
|
95
|
|
- id='Result'
|
96
|
|
- position='200'
|
97
|
|
- error='false'
|
98
|
177
|
numsubpods='1'
|
99
|
178
|
primary='true'>
|
100
|
179
|
<subpod title=''>
|
101
|
|
- <img src='http://www4c.wolframalpha.com/Calculate/MSP/MSP9751hfe101fc27?MSPStoreType=image/gif&s=53'
|
102
|
|
- alt='i'
|
103
|
|
- title='i'
|
104
|
|
- width='5'
|
105
|
|
- height='18' />
|
106
|
|
- <plaintext>i</plaintext>
|
|
180
|
+ <plaintext>∫1/xxlog(x)+constant</plaintext>
|
107
|
181
|
</subpod>
|
108
|
182
|
<states count='1'>
|
109
|
183
|
<state name='Step-by-step solution'
|
110
|
|
- input='Result__Step-by-step solution' />
|
|
184
|
+ input='IndefiniteIntegral__Step-by-step solution' />
|
111
|
185
|
</states>
|
|
186
|
+ <infos count='1'>
|
|
187
|
+ <info text='log(x) is the natural logarithm'>
|
|
188
|
+ <link url='http://reference.wolfram.com/mathematica/ref/Log.html'
|
|
189
|
+ text='Documentation'
|
|
190
|
+ title='Mathematica' />
|
|
191
|
+ <link url='http://functions.wolfram.com/ElementaryFunctions/Log'
|
|
192
|
+ text='Properties'
|
|
193
|
+ title='Wolfram Functions Site' />
|
|
194
|
+ <link url='http://mathworld.wolfram.com/NaturalLogarithm.html'
|
|
195
|
+ text='Definition'
|
|
196
|
+ title='MathWorld' />
|
|
197
|
+ </info>
|
|
198
|
+ </infos>
|
112
|
199
|
</pod>
|
113
|
|
- <pod title='Polar coordinates'
|
114
|
|
- scanner='Numeric'
|
115
|
|
- id='PolarCoordinates'
|
116
|
|
- position='300'
|
117
|
|
- error='false'
|
118
|
|
- numsubpods='1'>
|
119
|
|
- <subpod title=''>
|
120
|
|
- <img src='http://www4c.wolframalpha.com/Calculate/MSP/MSP97600003i83?MSPStoreType=image/gif&s=53'
|
121
|
|
- alt='r = 1 (radius), theta = 90° (angle)'
|
122
|
|
- title='r = 1 (radius), theta = 90° (angle)'
|
123
|
|
- width='209'
|
124
|
|
- height='18' />
|
125
|
|
- <plaintext>r = 1 (radius), theta = 90° (angle)</plaintext>
|
126
|
|
- </subpod>
|
127
|
|
- </pod>
|
128
|
|
- <pod title='Position in the complex plane'
|
129
|
|
- scanner='Numeric'
|
130
|
|
- id='PositionInTheComplexPlane'
|
131
|
|
- position='400'
|
132
|
|
- error='false'
|
133
|
|
- numsubpods='1'>
|
134
|
|
- <subpod title=''>
|
135
|
|
- <img src='http://www4c.wolframalpha.com/Calculate/MSP/MSP9771e10ficg4g?MSPStoreType=image/gif&s=53'
|
136
|
|
- alt=''
|
137
|
|
- title=''
|
138
|
|
- width='200'
|
139
|
|
- height='185' />
|
140
|
|
- <plaintext></plaintext>
|
141
|
|
- </subpod>
|
142
|
|
- </pod>
|
143
|
|
- <pod title='All 2nd roots of -1'
|
144
|
|
- scanner='RootsOfUnity'
|
145
|
|
- id=''
|
146
|
|
- position='500'
|
|
200
|
+ <pod title='Plots of the integral'
|
|
201
|
+ scanner='Integral'
|
|
202
|
+ id='Plot'
|
|
203
|
+ position='200'
|
147
|
204
|
error='false'
|
148
|
205
|
numsubpods='2'>
|
149
|
206
|
<subpod title=''>
|
150
|
|
- <img src='http://www4c.wolframalpha.com/Calculate/MSP/MSP9781hfe10fii?MSPStoreType=image/gif&s=53'
|
151
|
|
- alt='i (principal root)'
|
152
|
|
- title='i (principal root)'
|
153
|
|
- width='94'
|
154
|
|
- height='18' />
|
155
|
|
- <plaintext>i (principal root)</plaintext>
|
|
207
|
+ <plaintext></plaintext>
|
|
208
|
+ <states count='1'>
|
|
209
|
+ <statelist count='2'
|
|
210
|
+ value='Complex-valued plot'
|
|
211
|
+ delimiters=''>
|
|
212
|
+ <state name='Complex-valued plot'
|
|
213
|
+ input='Plot__1_Complex-valued plot' />
|
|
214
|
+ <state name='Real-valued plot'
|
|
215
|
+ input='Plot__1_Real-valued plot' />
|
|
216
|
+ </statelist>
|
|
217
|
+ </states>
|
156
|
218
|
</subpod>
|
157
|
219
|
<subpod title=''>
|
158
|
|
- <img src='http://www4c.wolframalpha.com/Calculate/MSP/MSP9791hfe16f2eh1?MSPStoreType=image/gif&s=53'
|
159
|
|
- alt='-i'
|
160
|
|
- title='-i'
|
161
|
|
- width='16'
|
162
|
|
- height='18' />
|
163
|
|
- <plaintext>-i</plaintext>
|
164
|
|
- </subpod>
|
165
|
|
- </pod>
|
166
|
|
- <pod title='Plot of all roots in the complex plane'
|
167
|
|
- scanner='RootsOfUnity'
|
168
|
|
- id='PlotOfAllRootsInTheComplexPlane'
|
169
|
|
- position='600'
|
170
|
|
- error='false'
|
171
|
|
- numsubpods='1'>
|
172
|
|
- <subpod title=''>
|
173
|
|
- <img src='http://www4c.wolframalpha.com/Calculate/MSP/MSP9801h0fi192f9?MSPStoreType=image/gif&s=53'
|
174
|
|
- alt=''
|
175
|
|
- title=''
|
176
|
|
- width='200'
|
177
|
|
- height='185' />
|
178
|
220
|
<plaintext></plaintext>
|
|
221
|
+ <states count='1'>
|
|
222
|
+ <statelist count='2'
|
|
223
|
+ value='Complex-valued plot'
|
|
224
|
+ delimiters=''>
|
|
225
|
+ <state name='Complex-valued plot'
|
|
226
|
+ input='Plot__2_Complex-valued plot' />
|
|
227
|
+ <state name='Real-valued plot'
|
|
228
|
+ input='Plot__2_Real-valued plot' />
|
|
229
|
+ </statelist>
|
|
230
|
+ </states>
|
179
|
231
|
</subpod>
|
180
|
232
|
</pod>
|
|
233
|
+ <assumptions count='1'>
|
|
234
|
+ <assumption type='Clash'
|
|
235
|
+ word='integral'
|
|
236
|
+ template='Assuming "${word}" is ${desc1}. Use as ${desc2} instead'
|
|
237
|
+ count='2'>
|
|
238
|
+ <value name='IntegralsWord'
|
|
239
|
+ desc='an integral'
|
|
240
|
+ input='*C.integral-_*IntegralsWord-' />
|
|
241
|
+ <value name='MathematicalFunctionIdentityPropertyClass'
|
|
242
|
+ desc='a function property'
|
|
243
|
+ input='*C.integral-_*MathematicalFunctionIdentityPropertyClass-' />
|
|
244
|
+ </assumption>
|
|
245
|
+ </assumptions>
|
181
|
246
|
</queryresult>
|
182
|
247
|
"""
|
183
|
248
|
response = mock.Mock(content=xml)
|
184
|
249
|
results = wolframalpha_api.response(response)
|
185
|
250
|
self.assertEqual(type(results), list)
|
186
|
|
- self.assertEqual(len(results), 1)
|
187
|
|
- self.assertIn("i", results[0]['answer'])
|
188
|
|
-
|
189
|
|
- xml = """<?xml version='1.0' encoding='UTF-8'?>
|
190
|
|
- <queryresult success='true'
|
191
|
|
- error='false'
|
192
|
|
- numpods='2'
|
193
|
|
- datatypes=''
|
194
|
|
- timedout='Integral'
|
195
|
|
- timedoutpods=''
|
196
|
|
- timing='1.245'
|
197
|
|
- parsetiming='0.194'
|
198
|
|
- parsetimedout='false'
|
199
|
|
- recalculate='http://www4b.wolframalpha.com/api/v2/recalc.jsp?id=MSPa77651gf1a1hie0ii051ea0e1c&s=3'
|
200
|
|
- id='MSPa77661gf1a1hie5c9d9a600003baifafc1211daef'
|
201
|
|
- host='http://www4b.wolframalpha.com'
|
202
|
|
- server='3'
|
203
|
|
- related='http://www4b.wolframalpha.com/api/v2/relatedQueries.jsp?id=MSPa77671gf1a1hie5c5hc2&s=3'
|
204
|
|
- version='2.6'>
|
205
|
|
- <pod title='Indefinite integral'
|
206
|
|
- scanner='Integral'
|
207
|
|
- id='IndefiniteIntegral'
|
208
|
|
- position='100'
|
209
|
|
- error='false'
|
210
|
|
- numsubpods='1'
|
211
|
|
- primary='true'>
|
212
|
|
- <subpod title=''>
|
213
|
|
- <img src='http://www4b.wolframalpha.com/Calculate/MSP/MSP776814b9492i9a7gb16?MSPStoreType=image/gif&s=3'
|
214
|
|
- alt=' integral 1/x dx = log(x)+constant'
|
215
|
|
- title=' integral 1/x dx = log(x)+constant'
|
216
|
|
- width='182'
|
217
|
|
- height='36' />
|
218
|
|
- <plaintext> integral 1/x dx = log(x)+constant</plaintext>
|
219
|
|
- </subpod>
|
220
|
|
- <states count='1'>
|
221
|
|
- <state name='Step-by-step solution'
|
222
|
|
- input='IndefiniteIntegral__Step-by-step solution' />
|
223
|
|
- </states>
|
224
|
|
- <infos count='1'>
|
225
|
|
- <info text='log(x) is the natural logarithm'>
|
226
|
|
- <img src='http://www4b.wolframalpha.com/Calculate/MSP/MSP77691g23eg440g89db?MSPStoreType=image/gif&s=3'
|
227
|
|
- alt='log(x) is the natural logarithm'
|
228
|
|
- title='log(x) is the natural logarithm'
|
229
|
|
- width='198'
|
230
|
|
- height='18' />
|
231
|
|
- <link url='http://reference.wolfram.com/mathematica/ref/Log.html'
|
232
|
|
- text='Documentation'
|
233
|
|
- title='Mathematica' />
|
234
|
|
- <link url='http://functions.wolfram.com/ElementaryFunctions/Log'
|
235
|
|
- text='Properties'
|
236
|
|
- title='Wolfram Functions Site' />
|
237
|
|
- <link url='http://mathworld.wolfram.com/NaturalLogarithm.html'
|
238
|
|
- text='Definition'
|
239
|
|
- title='MathWorld' />
|
240
|
|
- </info>
|
241
|
|
- </infos>
|
242
|
|
- </pod>
|
243
|
|
- <pod title='Plots of the integral'
|
244
|
|
- scanner='Integral'
|
245
|
|
- id='Plot'
|
246
|
|
- position='200'
|
247
|
|
- error='false'
|
248
|
|
- numsubpods='2'>
|
249
|
|
- <subpod title=''>
|
250
|
|
- <img src='http://www4b.wolframalpha.com/Calculate/MSP/MSP77701gf1a9d2eb630g9?MSPStoreType=image/gif&s=3'
|
251
|
|
- alt=''
|
252
|
|
- title=''
|
253
|
|
- width='334'
|
254
|
|
- height='128' />
|
255
|
|
- <plaintext></plaintext>
|
256
|
|
- <states count='1'>
|
257
|
|
- <statelist count='2'
|
258
|
|
- value='Complex-valued plot'
|
259
|
|
- delimiters=''>
|
260
|
|
- <state name='Complex-valued plot'
|
261
|
|
- input='Plot__1_Complex-valued plot' />
|
262
|
|
- <state name='Real-valued plot'
|
263
|
|
- input='Plot__1_Real-valued plot' />
|
264
|
|
- </statelist>
|
265
|
|
- </states>
|
266
|
|
- </subpod>
|
267
|
|
- <subpod title=''>
|
268
|
|
- <img src='http://www4b.wolframalpha.com/Calculate/MSP/MSP77711gf1ai29a34b0ab?MSPStoreType=image/gif&s=3'
|
269
|
|
- alt=''
|
270
|
|
- title=''
|
271
|
|
- width='334'
|
272
|
|
- height='133' />
|
273
|
|
- <plaintext></plaintext>
|
274
|
|
- <states count='1'>
|
275
|
|
- <statelist count='2'
|
276
|
|
- value='Complex-valued plot'
|
277
|
|
- delimiters=''>
|
278
|
|
- <state name='Complex-valued plot'
|
279
|
|
- input='Plot__2_Complex-valued plot' />
|
280
|
|
- <state name='Real-valued plot'
|
281
|
|
- input='Plot__2_Real-valued plot' />
|
282
|
|
- </statelist>
|
283
|
|
- </states>
|
284
|
|
- </subpod>
|
285
|
|
- </pod>
|
286
|
|
- </queryresult>
|
287
|
|
- """
|
288
|
|
- response = mock.Mock(content=xml)
|
289
|
|
- results = wolframalpha_api.response(response)
|
290
|
|
- self.assertEqual(type(results), list)
|
291
|
|
- self.assertEqual(len(results), 1)
|
|
251
|
+ self.assertEqual(len(results), 2)
|
292
|
252
|
self.assertIn("log(x)+c", results[0]['answer'])
|
|
253
|
+ # self.assertIn("integral 1/x - Wolfram|Alpha", results[1]['title'])
|
|
254
|
+ # self.assertIn("http://www.wolframalpha.com/input/?i=integral+1%2Fx", results[1]['url'])
|