Fixer Always Fetches Latest Exchange Rate Even When Date is Specified (#10596) (#10597)

* test that confirms the bug. Same test should pass after fix

* make use of correct api url
This commit is contained in:
tundebabzy 2017-08-31 10:00:15 +01:00 committed by Makarand Bauskar
parent 56e31d05e9
commit 7f8a259beb
2 changed files with 4 additions and 2 deletions

View File

@ -44,4 +44,5 @@ class TestCurrencyExchange(unittest.TestCase):
# Exchange rate as on 15th Dec, 2015, should be fetched from fixer.io
exchange_rate = get_exchange_rate("USD", "INR", "2015-12-15")
self.assertFalse(exchange_rate==60)
self.assertFalse(exchange_rate == 60)
self.assertEqual(exchange_rate, 66.894)

View File

@ -83,7 +83,8 @@ def get_exchange_rate(from_currency, to_currency, transaction_date=None):
if not value:
import requests
response = requests.get("http://api.fixer.io/latest", params={
api_url = "http://api.fixer.io/{0}".format(transaction_date)
response = requests.get(api_url, params={
"base": from_currency,
"symbols": to_currency
})