mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Currency update fix (#4303)
* Call function rather than just looking at it * Simple unit test POSTs to currency refresh endpoint * Check if rates have been updated
This commit is contained in:
parent
ce3dabedb6
commit
26c97db364
@ -154,7 +154,7 @@ class CurrencyRefreshView(APIView):
|
|||||||
|
|
||||||
from InvenTree.tasks import update_exchange_rates
|
from InvenTree.tasks import update_exchange_rates
|
||||||
|
|
||||||
update_exchange_rates
|
update_exchange_rates()
|
||||||
|
|
||||||
return Response({
|
return Response({
|
||||||
'success': 'Exchange rates updated',
|
'success': 'Exchange rates updated',
|
||||||
|
@ -912,3 +912,16 @@ class CurrencyAPITests(InvenTreeAPITestCase):
|
|||||||
|
|
||||||
self.assertIn('base_currency', response.data)
|
self.assertIn('base_currency', response.data)
|
||||||
self.assertIn('exchange_rates', response.data)
|
self.assertIn('exchange_rates', response.data)
|
||||||
|
|
||||||
|
def test_refresh_endpoint(self):
|
||||||
|
"""Call the 'refresh currencies' endpoint"""
|
||||||
|
|
||||||
|
from djmoney.contrib.exchange.models import Rate
|
||||||
|
|
||||||
|
# Delete any existing exchange rate data
|
||||||
|
Rate.objects.all().delete()
|
||||||
|
|
||||||
|
self.post(reverse('api-currency-refresh'))
|
||||||
|
|
||||||
|
# There should be some new exchange rate objects now
|
||||||
|
self.assertTrue(Rate.objects.all().exists())
|
||||||
|
Loading…
Reference in New Issue
Block a user