diff options
| author | Maxqia <contrib@maxqia.com> | 2016-05-02 17:06:17 -0700 |
|---|---|---|
| committer | Maxqia <contrib@maxqia.com> | 2016-05-03 18:59:30 -0700 |
| commit | 56e53c929777a0a47d9e702219dbab4326c63010 (patch) | |
| tree | 7222aa5b7bfde71d23b6332363ae9df23ba7dc4e /tests | |
| parent | dcc8f996d429e3467f9dab27ed072737e919c2e8 (diff) | |
[fix] currency_convert: make unit tests pass
also make regex more efficent and normalize 's'es
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/unit/engines/test_currency_convert.py | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/tests/unit/engines/test_currency_convert.py b/tests/unit/engines/test_currency_convert.py index 84ec3b742..b7720569f 100644 --- a/tests/unit/engines/test_currency_convert.py +++ b/tests/unit/engines/test_currency_convert.py @@ -14,23 +14,19 @@ class TestCurrencyConvertEngine(SearxTestCase): params = currency_convert.request(query, dicto) self.assertNotIn('url', params) - query = '1.1.1 EUR in USD' - params = currency_convert.request(query, dicto) - self.assertNotIn('url', params) - - query = '10 eur in usd' + query = 'convert 10 Pound Sterlings to United States Dollars' params = currency_convert.request(query, dicto) self.assertIn('url', params) self.assertIn('finance.yahoo.com', params['url']) - self.assertIn('EUR', params['url']) + self.assertIn('GBP', params['url']) self.assertIn('USD', params['url']) def test_response(self): dicto = defaultdict(dict) dicto['ammount'] = float(10) - dicto['from'] = "EUR" + dicto['from'] = "GBP" dicto['to'] = "USD" - dicto['from_name'] = "euro" + dicto['from_name'] = "pound sterling" dicto['to_name'] = "United States dollar" response = mock.Mock(text='a,b,c,d', search_params=dicto) self.assertEqual(currency_convert.response(response), []) @@ -40,7 +36,8 @@ class TestCurrencyConvertEngine(SearxTestCase): results = currency_convert.response(response) self.assertEqual(type(results), list) self.assertEqual(len(results), 1) - self.assertEqual(results[0]['answer'], '10.0 EUR = 5.0 USD, 1 EUR (euro) = 0.5 USD (United States dollar)') + self.assertEqual(results[0]['answer'], '10.0 GBP = 5.0 USD, 1 GBP (pound sterling)' + + ' = 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.0-eur-to-usd.html') + now_date + '/10.0-gbp-to-usd.html') |