2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-08-09 21:30:54 +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:
Oliver
2023-03-08 15:22:08 +11:00
committed by GitHub
parent 9c594ed52b
commit 2dfea9b825
20 changed files with 258 additions and 180 deletions

View File

@@ -17,11 +17,14 @@ class CompanyTest(InvenTreeAPITestCase):
'purchase_order.change',
]
def setUp(self):
@classmethod
def setUpTestData(cls):
"""Perform initialization for the unit test class"""
super().setUp()
self.acme = Company.objects.create(name='ACME', description='Supplier', is_customer=False, is_supplier=True)
super().setUpTestData()
# Create some company objects to work with
cls.acme = Company.objects.create(name='ACME', description='Supplier', is_customer=False, is_supplier=True)
Company.objects.create(name='Drippy Cup Co.', description='Customer', is_customer=True, is_supplier=False)
Company.objects.create(name='Sippy Cup Emporium', description='Another supplier')

View File

@@ -26,8 +26,12 @@ class CompanySimpleTest(TestCase):
'price_breaks',
]
def setUp(self):
@classmethod
def setUpTestData(cls):
"""Perform initialization for the tests in this class"""
super().setUpTestData()
Company.objects.create(name='ABC Co.',
description='Seller of ABC products',
website='www.abc-sales.com',
@@ -35,10 +39,10 @@ class CompanySimpleTest(TestCase):
is_customer=False,
is_supplier=True)
self.acme0001 = SupplierPart.objects.get(SKU='ACME0001')
self.acme0002 = SupplierPart.objects.get(SKU='ACME0002')
self.zerglphs = SupplierPart.objects.get(SKU='ZERGLPHS')
self.zergm312 = SupplierPart.objects.get(SKU='ZERGM312')
cls.acme0001 = SupplierPart.objects.get(SKU='ACME0001')
cls.acme0002 = SupplierPart.objects.get(SKU='ACME0002')
cls.zerglphs = SupplierPart.objects.get(SKU='ZERGLPHS')
cls.zergm312 = SupplierPart.objects.get(SKU='ZERGM312')
def test_company_model(self):
"""Tests for the company model data"""