|
@@ -124,16 +124,16 @@ class TestWolframAlphaNoAPIEngine(SearxTestCase):
|
124
|
124
|
results = wolframalpha_noapi.response(response)
|
125
|
125
|
self.assertEqual(type(results), list)
|
126
|
126
|
self.assertEqual(len(results), 2)
|
127
|
|
- self.assertIn('input_plaintext', results[0]['infobox'])
|
|
127
|
+ self.assertEqual('input_plaintext', results[0]['infobox'])
|
128
|
128
|
|
129
|
129
|
self.assertEqual(len(results[0]['attributes']), 3)
|
130
|
|
- self.assertIn('Input', results[0]['attributes'][0]['label'])
|
131
|
|
- self.assertIn('input_plaintext', results[0]['attributes'][0]['value'])
|
132
|
|
- self.assertIn('Result', results[0]['attributes'][1]['label'])
|
133
|
|
- self.assertIn('result_plaintext', results[0]['attributes'][1]['value'])
|
134
|
|
- self.assertIn('Manipulatives illustration', results[0]['attributes'][2]['label'])
|
135
|
|
- self.assertIn('illustration_img_src.gif', results[0]['attributes'][2]['image']['src'])
|
136
|
|
- self.assertIn('illustration_img_alt', results[0]['attributes'][2]['image']['alt'])
|
|
130
|
+ self.assertEqual('Input', results[0]['attributes'][0]['label'])
|
|
131
|
+ self.assertEqual('input_plaintext', results[0]['attributes'][0]['value'])
|
|
132
|
+ self.assertEqual('Result', results[0]['attributes'][1]['label'])
|
|
133
|
+ self.assertEqual('result_plaintext', results[0]['attributes'][1]['value'])
|
|
134
|
+ self.assertEqual('Manipulatives illustration', results[0]['attributes'][2]['label'])
|
|
135
|
+ self.assertEqual('illustration_img_src.gif', results[0]['attributes'][2]['image']['src'])
|
|
136
|
+ self.assertEqual('illustration_img_alt', results[0]['attributes'][2]['image']['alt'])
|
137
|
137
|
|
138
|
138
|
self.assertEqual(len(results[0]['urls']), 1)
|
139
|
139
|
|
|
@@ -184,8 +184,19 @@ class TestWolframAlphaNoAPIEngine(SearxTestCase):
|
184
|
184
|
],
|
185
|
185
|
"id" : "Plot",
|
186
|
186
|
"error" : false,
|
187
|
|
- "numsubpods" : 0,
|
188
|
|
- "async" : "invalid_async_url"
|
|
187
|
+ "numsubpods" : 1,
|
|
188
|
+ "subpods" : [
|
|
189
|
+ {
|
|
190
|
+ "title" : "",
|
|
191
|
+ "img" : {
|
|
192
|
+ "src" : "plot.gif",
|
|
193
|
+ "alt" : "plot_alt",
|
|
194
|
+ "title" : "plot_title"
|
|
195
|
+ },
|
|
196
|
+ "plaintext" : "",
|
|
197
|
+ "minput" : "plot_minput"
|
|
198
|
+ }
|
|
199
|
+ ]
|
189
|
200
|
}
|
190
|
201
|
]
|
191
|
202
|
}}
|
|
@@ -194,11 +205,14 @@ class TestWolframAlphaNoAPIEngine(SearxTestCase):
|
194
|
205
|
results = wolframalpha_noapi.response(response)
|
195
|
206
|
self.assertEqual(type(results), list)
|
196
|
207
|
self.assertEqual(len(results), 2)
|
197
|
|
- self.assertIn('integral_plaintext', results[0]['infobox'])
|
|
208
|
+ self.assertEqual('integral_plaintext', results[0]['infobox'])
|
198
|
209
|
|
199
|
|
- self.assertEqual(len(results[0]['attributes']), 1)
|
200
|
|
- self.assertIn('Indefinite integral', results[0]['attributes'][0]['label'])
|
201
|
|
- self.assertIn('integral_plaintext', results[0]['attributes'][0]['value'])
|
|
210
|
+ self.assertEqual(len(results[0]['attributes']), 2)
|
|
211
|
+ self.assertEqual('Indefinite integral', results[0]['attributes'][0]['label'])
|
|
212
|
+ self.assertEqual('integral_plaintext', results[0]['attributes'][0]['value'])
|
|
213
|
+ self.assertEqual('Plot of the integral', results[0]['attributes'][1]['label'])
|
|
214
|
+ self.assertEqual('plot.gif', results[0]['attributes'][1]['image']['src'])
|
|
215
|
+ self.assertEqual('plot_alt', results[0]['attributes'][1]['image']['alt'])
|
202
|
216
|
|
203
|
217
|
self.assertEqual(len(results[0]['urls']), 1)
|
204
|
218
|
|
|
@@ -206,33 +220,3 @@ class TestWolframAlphaNoAPIEngine(SearxTestCase):
|
206
|
220
|
self.assertEqual('Wolfram|Alpha', results[0]['urls'][0]['title'])
|
207
|
221
|
self.assertEqual(referer_url, results[1]['url'])
|
208
|
222
|
self.assertEqual('Wolfram|Alpha', results[1]['title'])
|
209
|
|
-
|
210
|
|
- def test_parse_async_pod(self):
|
211
|
|
- self.assertRaises(AttributeError, wolframalpha_noapi.parse_async_pod, None)
|
212
|
|
- self.assertRaises(AttributeError, wolframalpha_noapi.parse_async_pod, [])
|
213
|
|
- self.assertRaises(AttributeError, wolframalpha_noapi.parse_async_pod, '')
|
214
|
|
- self.assertRaises(AttributeError, wolframalpha_noapi.parse_async_pod, '[]')
|
215
|
|
-
|
216
|
|
- # test plot
|
217
|
|
- xml = '''<?xml version='1.0' encoding='UTF-8'?>
|
218
|
|
- <pod title='Plot'
|
219
|
|
- scanner='Plot'
|
220
|
|
- id='Plot'
|
221
|
|
- error='false'
|
222
|
|
- numsubpods='1'>
|
223
|
|
- <subpod title=''>
|
224
|
|
- <img src='plot_img_src.gif'
|
225
|
|
- alt='plot_img_alt'
|
226
|
|
- title='plot_img_title' />
|
227
|
|
- <plaintext>plot_plaintext</plaintext>
|
228
|
|
- <minput>plot_minput</minput>
|
229
|
|
- </subpod>
|
230
|
|
- </pod>
|
231
|
|
- '''
|
232
|
|
- response = mock.Mock(content=xml)
|
233
|
|
- pod = wolframalpha_noapi.parse_async_pod(response)
|
234
|
|
- self.assertEqual(len(pod['subpods']), 1)
|
235
|
|
- self.assertEqual('', pod['subpods'][0]['title'])
|
236
|
|
- self.assertEqual('plot_plaintext', pod['subpods'][0]['plaintext'])
|
237
|
|
- self.assertEqual('plot_img_src.gif', pod['subpods'][0]['img']['src'])
|
238
|
|
- self.assertEqual('plot_img_alt', pod['subpods'][0]['img']['alt'])
|