mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-02 11:40:58 +00:00
Unit test speed improvements (#4463)
* Unit test speed improvements - Move from insantiating data in setUp to setUpTestData * Update UserMixin class for API testing * Bunch of test updates * Further test updates * Test fixes * Add allowances for exchange rate server not responding * Fixes for group role test
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
"""Tests for mechanisms in common."""
|
||||
|
||||
import json
|
||||
import time
|
||||
from datetime import timedelta
|
||||
from http import HTTPStatus
|
||||
|
||||
@ -921,7 +922,16 @@ class CurrencyAPITests(InvenTreeAPITestCase):
|
||||
# Delete any existing exchange rate data
|
||||
Rate.objects.all().delete()
|
||||
|
||||
self.post(reverse('api-currency-refresh'))
|
||||
# Updating via the external exchange may not work every time
|
||||
for _idx in range(5):
|
||||
self.post(reverse('api-currency-refresh'))
|
||||
|
||||
# There should be some new exchange rate objects now
|
||||
self.assertTrue(Rate.objects.all().exists())
|
||||
# There should be some new exchange rate objects now
|
||||
if Rate.objects.all().exists():
|
||||
# Exit early
|
||||
return
|
||||
|
||||
# Delay and try again
|
||||
time.sleep(10)
|
||||
|
||||
raise TimeoutError("Could not refresh currency exchange data after 5 attempts")
|
||||
|
Reference in New Issue
Block a user