summaryrefslogtreecommitdiff
path: root/searx/tests
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2015-05-12 20:52:08 +0200
committerAlexandre Flament <alex@al-f.net>2015-05-12 20:52:08 +0200
commit5525625daec57934420feded2a692cecdd4c9c9b (patch)
tree71a9dc7abb08b349b7c29c696010a7feefa8e669 /searx/tests
parent3683b358771badc9b886931b816b87632c7efa99 (diff)
[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.
Diffstat (limited to 'searx/tests')
-rw-r--r--searx/tests/engines/test_currency_convert.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/searx/tests/engines/test_currency_convert.py b/searx/tests/engines/test_currency_convert.py
index 579c5cc1f..84ec3b742 100644
--- a/searx/tests/engines/test_currency_convert.py
+++ b/searx/tests/engines/test_currency_convert.py
@@ -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')