@@ -1,6 +1,5 @@
1# -*- coding: utf-8 -*-
1# -*- coding: utf-8 -*-
2from collections import defaultdict
2from collections import defaultdict
4from searx.engines import wolframalpha_noapi
3from searx.engines import wolframalpha_noapi
5from searx.testing import SearxTestCase
4from searx.testing import SearxTestCase
@@ -21,173 +20,4 @@ class TestWolframAlphaNoAPIEngine(SearxTestCase):
21 self.assertRaises(AttributeError, wolframalpha_noapi.response, [])
20 self.assertRaises(AttributeError, wolframalpha_noapi.response, [])
22 self.assertRaises(AttributeError, wolframalpha_noapi.response, '')
21 self.assertRaises(AttributeError, wolframalpha_noapi.response, '')
23 self.assertRaises(AttributeError, wolframalpha_noapi.response, '[]')
22 self.assertRaises(AttributeError, wolframalpha_noapi.response, '[]')
27− <title> Parangaricutirimícuaro - Wolfram|Alpha</title>
28− <meta charset="utf-8" />
31− <p class="pfail">Wolfram|Alpha doesn't know how to interpret your input.</p>
34− <span class="tip-title">Tip: </span>
35− Check your spelling, and use English
36− <span class="tip-extra"></span>
44− response = mock.Mock(text=html)
45− self.assertEqual(wolframalpha_noapi.response(response), [])
49− <title> sqrt(-1) - Wolfram|Alpha</title>
50− <meta charset="utf-8" />
52− <script type="text/javascript">
54− if (typeof context.jsonArray.popups.pod_0100 == "undefined" ) {
55− context.jsonArray.popups.pod_0100 = [];
57− context.jsonArray.popups.pod_0100.push( {"stringified": "sqrt(-1)","mInput": "","mOutput": ""});
61− if (typeof context.jsonArray.popups.pod_0200 == "undefined" ) {
62− context.jsonArray.popups.pod_0200 = [];
64− context.jsonArray.popups.pod_0200.push( {"stringified": "i","mInput": "","mOutput": ""});
71− response = mock.Mock(text=html)
72− results = wolframalpha_noapi.response(response)
73− self.assertEqual(type(results), list)
74− self.assertEqual(len(results), 2)
75− self.assertEquals('i', results[0]['answer'])
76− self.assertIn('sqrt(-1) - Wolfram|Alpha', results[1]['title'])
77− self.assertEquals('http://www.wolframalpha.com/input/?i=+sqrt%28-1%29', results[1]['url'])
81− <title> integral 1/x - Wolfram|Alpha</title>
82− <meta charset="utf-8" />
84− <script type="text/javascript">
86− if (typeof context.jsonArray.popups.pod_0100 == "undefined" ) {
87− context.jsonArray.popups.pod_0100 = [];
89− context.jsonArray.popups.pod_0100.push( {"stringified": "integral 1\/x dx = log(x)+constant"});
96− response = mock.Mock(text=html)
97− results = wolframalpha_noapi.response(response)
98− self.assertEqual(type(results), list)
99− self.assertEqual(len(results), 2)
100− self.assertIn('log(x)+c', results[0]['answer'])
101− self.assertIn('integral 1/x - Wolfram|Alpha', results[1]['title'])
102− self.assertEquals('http://www.wolframalpha.com/input/?i=+integral+1%2Fx', results[1]['url'])
106− <title> ∫1/x x - Wolfram|Alpha</title>
107− <meta charset="utf-8" />
109− <script type="text/javascript">
111− if (typeof context.jsonArray.popups.pod_0100 == "undefined" ) {
112− context.jsonArray.popups.pod_0100 = [];
114− context.jsonArray.popups.pod_0100.push( {"stringified": "integral 1\/x dx = log(x)+constant"});
120− # test input in mathematical notation
121− response = mock.Mock(text=html)
122− results = wolframalpha_noapi.response(response)
123− self.assertEqual(type(results), list)
124− self.assertEqual(len(results), 2)
125− self.assertIn('log(x)+c', results[0]['answer'])
126− self.assertIn('∫1/x x - Wolfram|Alpha'.decode('utf-8'), results[1]['title'])
127− self.assertEquals('http://www.wolframalpha.com/input/?i=+%E2%88%AB1%2Fx+%EF%9D%8Cx', results[1]['url'])
131− <title> 1 euro to yen - Wolfram|Alpha</title>
132− <meta charset="utf-8" />
134− <script type="text/javascript">
136− if (typeof context.jsonArray.popups.pod_0100 == "undefined" ) {
137− context.jsonArray.popups.pod_0100 = [];
139− context.jsonArray.popups.pod_0100.push( {"stringified": "convert euro1 (euro) to Japanese yen"});
143− if (typeof context.jsonArray.popups.pod_0200 == "undefined" ) {
144− context.jsonArray.popups.pod_0200 = [];
146− context.jsonArray.popups.pod_0200.push( {"stringified": "¥130.5 (Japanese yen)"});
152− # test output with htmlentity
153− response = mock.Mock(text=html)
154− results = wolframalpha_noapi.response(response)
155− self.assertEqual(type(results), list)
156− self.assertEqual(len(results), 2)
157− self.assertIn('¥'.decode('utf-8'), results[0]['answer'])
158− self.assertIn('1 euro to yen - Wolfram|Alpha', results[1]['title'])
159− self.assertEquals('http://www.wolframalpha.com/input/?i=+1+euro+to+yen', results[1]['url'])
163− <title> distance from nairobi to kyoto in inches - Wolfram|Alpha</title>
164− <meta charset="utf-8" />
166− <script type="text/javascript">
168− if (typeof context.jsonArray.popups.pod_0100 == "undefined" ) {
169− context.jsonArray.popups.pod_0100 = [];
171−[...].pod_0100.push( {"stringified": "convert distance | from | Nairobi, Kenya\nto | Kyoto, Japan to inches"});
175− if (typeof context.jsonArray.popups.pod_0200 == "undefined" ) {
176− context.jsonArray.popups.pod_0200 = [];
178−pod_0200.push({"stringified": "4.295×10^8 inches","mOutput": "Quantity[4.295×10^8,&quot;Inches&quot;]"});
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',