forked from Icycoide/searxng
[enh] currency_convert engine: user can write "1 dollars in euros" instead of "1 USD in EUR".
The currency names are fetched wikidata and store into a static file : searx/data/currencies.json This file is loaded when the currency_converter is loaded. A database is perhaps more appropiated.
This commit is contained in:
parent
3683b35877
commit
5525625dae
4 changed files with 7868 additions and 6 deletions
|
@ -27,9 +27,11 @@ class TestCurrencyConvertEngine(SearxTestCase):
|
|||
|
||||
def test_response(self):
|
||||
dicto = defaultdict(dict)
|
||||
dicto['ammount'] = 10
|
||||
dicto['ammount'] = float(10)
|
||||
dicto['from'] = "EUR"
|
||||
dicto['to'] = "USD"
|
||||
dicto['from_name'] = "euro"
|
||||
dicto['to_name'] = "United States dollar"
|
||||
response = mock.Mock(text='a,b,c,d', search_params=dicto)
|
||||
self.assertEqual(currency_convert.response(response), [])
|
||||
|
||||
|
@ -38,7 +40,7 @@ class TestCurrencyConvertEngine(SearxTestCase):
|
|||
results = currency_convert.response(response)
|
||||
self.assertEqual(type(results), list)
|
||||
self.assertEqual(len(results), 1)
|
||||
self.assertEqual(results[0]['answer'], '10 EUR = 5.0 USD (1 EUR = 0.5 USD)')
|
||||
self.assertEqual(results[0]['answer'], '10.0 EUR = 5.0 USD, 1 EUR (euro) = 0.5 USD (United States dollar)')
|
||||
now_date = datetime.now().strftime('%Y%m%d')
|
||||
self.assertEqual(results[0]['url'], 'https://finance.yahoo.com/currency/converter-results/' +
|
||||
now_date + '/10-eur-to-usd.html')
|
||||
now_date + '/10.0-eur-to-usd.html')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue