|
@@ -149,11 +149,45 @@ class TestWolframAlphaNoAPIEngine(SearxTestCase):
|
149
|
149
|
</body>
|
150
|
150
|
</html>
|
151
|
151
|
"""
|
152
|
|
- # test output in htmlentity
|
|
152
|
+ # test output with htmlentity
|
153
|
153
|
response = mock.Mock(text=html)
|
154
|
154
|
results = wolframalpha_noapi.response(response)
|
155
|
155
|
self.assertEqual(type(results), list)
|
156
|
156
|
self.assertEqual(len(results), 2)
|
157
|
|
- self.assertIn("¥".decode('utf-8'), results[0]['answer'])
|
|
157
|
+ self.assertIn('¥'.decode('utf-8'), results[0]['answer'])
|
158
|
158
|
self.assertIn('1 euro to yen - Wolfram|Alpha', results[1]['title'])
|
159
|
159
|
self.assertEquals('http://www.wolframalpha.com/input/?i=+1+euro+to+yen', results[1]['url'])
|
|
160
|
+
|
|
161
|
+ html = """
|
|
162
|
+ <!DOCTYPE html>
|
|
163
|
+ <title> distance from nairobi to kyoto in inches - Wolfram|Alpha</title>
|
|
164
|
+ <meta charset="utf-8" />
|
|
165
|
+ <body>
|
|
166
|
+ <script type="text/javascript">
|
|
167
|
+ try {
|
|
168
|
+ if (typeof context.jsonArray.popups.pod_0100 == "undefined" ) {
|
|
169
|
+ context.jsonArray.popups.pod_0100 = [];
|
|
170
|
+ }
|
|
171
|
+[...].pod_0100.push( {"stringified": "convert distance | from | Nairobi, Kenya\nto | Kyoto, Japan to inches"});
|
|
172
|
+ } catch(e) { }
|
|
173
|
+
|
|
174
|
+ try {
|
|
175
|
+ if (typeof context.jsonArray.popups.pod_0200 == "undefined" ) {
|
|
176
|
+ context.jsonArray.popups.pod_0200 = [];
|
|
177
|
+ }
|
|
178
|
+pod_0200.push({"stringified": "4.295×10^8 inches","mOutput": "Quantity[4.295×10^8,&quot;Inches&quot;]"});
|
|
179
|
+
|
|
180
|
+ } catch(e) { }
|
|
181
|
+ </script>
|
|
182
|
+ </body>
|
|
183
|
+ </html>
|
|
184
|
+ """
|
|
185
|
+ # test output with utf-8 character
|
|
186
|
+ response = mock.Mock(text=html)
|
|
187
|
+ results = wolframalpha_noapi.response(response)
|
|
188
|
+ self.assertEqual(type(results), list)
|
|
189
|
+ self.assertEqual(len(results), 2)
|
|
190
|
+ self.assertIn('4.295×10^8 inches'.decode('utf-8'), results[0]['answer'])
|
|
191
|
+ self.assertIn('distance from nairobi to kyoto in inches - Wolfram|Alpha', results[1]['title'])
|
|
192
|
+ self.assertEquals('http://www.wolframalpha.com/input/?i=+distance+from+nairobi+to+kyoto+in+inches',
|
|
193
|
+ results[1]['url'])
|