on master help sign in
Fixed unittests.
commita1d1a50149b76545086fd2639ff58797007e435e authorpyrrh0n1c <pyrrh0n1c@protonmail.com> dateTue 7 Nov 2017, 14:49 (9 years ago) parent4340c0b
1 file changed+7−6
tests/unit/engines/test_currency_convert.py+7−6
tests/unit/engines/test_currency_convert.py+7−6
@@ -17,7 +17,7 @@ class TestCurrencyConvertEngine(SearxTestCase):
1717 query = b'convert 10 Pound Sterlings to United States Dollars'
1818 params = currency_convert.request(query, dicto)
1919 self.assertIn('url', params)
20− self.assertIn('finance.yahoo.com', params['url'])
20+ self.assertIn('finance.google.com', params['url'])
2121 self.assertIn('GBP', params['url'])
2222 self.assertIn('USD', params['url'])
2323
@@ -31,13 +31,14 @@ class TestCurrencyConvertEngine(SearxTestCase):
3131 response = mock.Mock(text='a,b,c,d', search_params=dicto)
3232 self.assertEqual(currency_convert.response(response), [])
3333
34− csv = "2,0.5,1"
35− response = mock.Mock(text=csv, search_params=dicto)
34+ body = "<span class=bld>0.5 {}</span>".format(dicto['to'])
35+ response = mock.Mock(text=body, search_params=dicto)
3636 results = currency_convert.response(response)
3737 self.assertEqual(type(results), list)
3838 self.assertEqual(len(results), 1)
3939 self.assertEqual(results[0]['answer'], '10.0 GBP = 5.0 USD, 1 GBP (pound sterling)' +
4040 ' = 0.5 USD (United States dollar)')
41− now_date = datetime.now().strftime('%Y%m%d')
42− self.assertEqual(results[0]['url'], 'https://finance.yahoo.com/currency/converter-results/' +
43− now_date + '/10.0-gbp-to-usd.html')
41+
42+ target_url = 'https://finance.google.com/finance?q={}{}'.format(
43+ dicto['from'], dicto['to'])
44+ self.assertEqual(results[0]['url'], target_url)