diff --git a/exchange/cache.py b/exchange/cache.py index eff210d..996a67f 100644 --- a/exchange/cache.py +++ b/exchange/cache.py @@ -31,8 +31,10 @@ def _get_cache_key(source_currency, target_currency): def update_rates_cached(): rates = ExchangeRate.objects.all() - cache_map = {_get_cache_key(rate.source.code, rate.target.code): rate.rate - for rate in rates} + cache_map = dict( + ((_get_cache_key(rate.source.code, rate.target.code), rate.rate) + for rate in rates) + ) cache.set_many(cache_map, timeout=CACHE_TIMEOUT) local_cache.clear() return cache_map @@ -49,6 +51,6 @@ def get_rate_cached(source_currency, target_currency): def get_rates_cached(args_list): - key_map = {_get_cache_key(*args): args for args in args_list} + key_map = dict(((_get_cache_key(*args), args) for args in args_list)) cache_map = cache.get_many(key_map.keys()) - return {key_map[key]: cache_map.get(key) for key in key_map.keys()} + return dict(((key_map[key], cache_map.get(key)) for key in key_map.keys())) diff --git a/exchange/conversion.py b/exchange/conversion.py index 400cbd8..ebfb057 100644 --- a/exchange/conversion.py +++ b/exchange/conversion.py @@ -61,16 +61,16 @@ def get_rates(currencies): sources.append(source) targets.append(target) else: - rate_map = {c: None for c in currencies} + rate_map = dict(((c, None) for c in currencies)) sources = map(itemgetter(0), currencies) targets = map(itemgetter(1), currencies) rates = ExchangeRate.objects.filter( source__code__in=sources, target__code__in=targets).values_list( - 'source__code', - 'target__code', - 'rate') + 'source__code', + 'target__code', + 'rate') for source, target, rate in rates: key = (source, target) diff --git a/test_project/settings.py b/test_project/settings.py index 2beb02d..ddfa060 100644 --- a/test_project/settings.py +++ b/test_project/settings.py @@ -10,3 +10,5 @@ TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' OPENEXCHANGERATES_API_KEY = '' + +SECRET_KEY = ''