refactor(base): adjust functional model test to use fixture kwargs

ref: #883 #735
This commit is contained in:
2025-07-24 15:34:15 +09:30
parent 482014004c
commit 6e1d0c747d
3 changed files with 54 additions and 69 deletions

View File

@ -10,23 +10,21 @@ class ModelTestCases:
This test suite contains all of the functional common tests for **ALL**
Centurion Models.
For this test suite to function the following class attributes must be set
for all classes that inherit from this class:
For this test suite to function the following fixtures must be available
for this class:
- `kwargs_create_item: dict = {}`
- model
_Dict of the models fields and the values required for
`model.objects.create()`_
- model_kwargs
This attribute can either be a variable or a property. This attribute along
with any prefixed `paremetized_` will be merged from each class in the
Attribute prefixed `paremetized_` will be merged from each class in the
inheritence chain. In addition this object must return a dict if defined.
"""
@pytest.fixture( scope = 'function' )
def created_model(self, request, django_db_blocker, model, user):
def created_model(self, django_db_blocker, model, model_kwargs):
if model._meta.abstract:
@ -37,16 +35,14 @@ class ModelTestCases:
with django_db_blocker.unblock():
model_object = model.objects.create(
**request.cls.kwargs_create_item
**model_kwargs
)
yield model_object
yield model_object
with django_db_blocker.unblock():
@property
def kwargs_create_item(self):
return {}
model_object.delete()