|
@@ -17,7 +17,7 @@ class TestCurrencyConvertEngine(SearxTestCase):
|
17
|
17
|
query = b'convert 10 Pound Sterlings to United States Dollars'
|
18
|
18
|
params = currency_convert.request(query, dicto)
|
19
|
19
|
self.assertIn('url', params)
|
20
|
|
- self.assertIn('finance.google.com', params['url'])
|
|
20
|
+ self.assertIn('duckduckgo.com', params['url'])
|
21
|
21
|
self.assertIn('GBP', params['url'])
|
22
|
22
|
self.assertIn('USD', params['url'])
|
23
|
23
|
|
|
@@ -30,8 +30,20 @@ class TestCurrencyConvertEngine(SearxTestCase):
|
30
|
30
|
dicto['to_name'] = "United States dollar"
|
31
|
31
|
response = mock.Mock(text='a,b,c,d', search_params=dicto)
|
32
|
32
|
self.assertEqual(currency_convert.response(response), [])
|
33
|
|
-
|
34
|
|
- body = "<span class=bld>0.5 {}</span>".format(dicto['to'])
|
|
33
|
+ body = """ddg_spice_currency(
|
|
34
|
+ {
|
|
35
|
+ "conversion":{
|
|
36
|
+ "converted-amount": "0.5"
|
|
37
|
+ },
|
|
38
|
+ "topConversions":[
|
|
39
|
+ {
|
|
40
|
+ },
|
|
41
|
+ {
|
|
42
|
+ }
|
|
43
|
+ ]
|
|
44
|
+ }
|
|
45
|
+ );
|
|
46
|
+ """
|
35
|
47
|
response = mock.Mock(text=body, search_params=dicto)
|
36
|
48
|
results = currency_convert.response(response)
|
37
|
49
|
self.assertEqual(type(results), list)
|
|
@@ -39,6 +51,6 @@ class TestCurrencyConvertEngine(SearxTestCase):
|
39
|
51
|
self.assertEqual(results[0]['answer'], '10.0 GBP = 5.0 USD, 1 GBP (pound sterling)' +
|
40
|
52
|
' = 0.5 USD (United States dollar)')
|
41
|
53
|
|
42
|
|
- target_url = 'https://finance.google.com/finance?q={}{}'.format(
|
|
54
|
+ target_url = 'https://duckduckgo.com/js/spice/currency/1/{}/{}'.format(
|
43
|
55
|
dicto['from'], dicto['to'])
|
44
|
56
|
self.assertEqual(results[0]['url'], target_url)
|