mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-03 22:55:43 +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:
		@@ -154,7 +154,7 @@ class CurrencyRefreshView(APIView):
 | 
			
		||||
 | 
			
		||||
        from InvenTree.tasks import update_exchange_rates
 | 
			
		||||
 | 
			
		||||
        update_exchange_rates
 | 
			
		||||
        update_exchange_rates()
 | 
			
		||||
 | 
			
		||||
        return Response({
 | 
			
		||||
            'success': 'Exchange rates updated',
 | 
			
		||||
 
 | 
			
		||||
@@ -912,3 +912,16 @@ class CurrencyAPITests(InvenTreeAPITestCase):
 | 
			
		||||
 | 
			
		||||
        self.assertIn('base_currency', 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())
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user