test(core): Add Base Centurion model Functional Test Suite

ref: #773 #767
This commit is contained in:
2025-05-26 13:04:37 +09:30
parent d86b07b4fa
commit 660da485cd
4 changed files with 85 additions and 0 deletions

View File

@ -266,6 +266,15 @@ def pytest_generate_tests(metafunc):
@pytest.fixture( scope = 'function')
def content_type():
from django.contrib.contenttypes.models import ContentType
yield ContentType
@pytest.fixture( scope = 'class')
def create_model(request, django_db_blocker):

View File

@ -0,0 +1,14 @@
import pytest
from core.models.centurion import CenturionModel
@pytest.fixture( scope = 'class')
def model(request):
request.cls.model = CenturionModel
yield request.cls.model
del request.cls.model

View File

@ -0,0 +1,61 @@
import pytest
from django.apps import apps
from access.tests.functional.tenancy_abstract.test_functional_tenancy_abstract_model import (
TenancyAbstractModelInheritedCases
)
@pytest.mark.centurion_models
class CenturionAbstractModelTestCases(
TenancyAbstractModelInheritedCases
):
kwargs_create_item = {
'model_notes': 'model notes txt',
'created': '2025-05-23T00:00',
}
def test_model_create_has_history_entry(self, content_type, created_model, model):
"""Model Created
Ensure that the model when created, added a `create` Audit History
entry.
"""
if model._meta.abstract:
pytest.xfail( reason = 'Model is an Abstract Model and can not be created.' )
history_model = apps.get_model( created_model._meta.app_label, created_model.get_history_model_name() )
entry = history_model.objects.get(
model = created_model,
content_type = content_type.objects.get(
app_label = created_model._meta.app_label,
model = created_model._meta.model_name
)
)
assert entry.model == created_model
class CenturionAbstractModelInheritedCases(
CenturionAbstractModelTestCases,
):
pass
class CenturionAbstractModelPyTest(
CenturionAbstractModelTestCases,
):
pass

View File

@ -1043,6 +1043,7 @@ log_cli_date_format = '%Y-%m-%d %H:%M:%S'
markers = [
"audit_models: Selects Audit models...",
"centurion_models: Selects Centurion models",
"functional: Selects all Functional tests.",
"meta_models: Selects Meta models",
"models: Selects all models tests.",
"tenancy_models: Selects Tenancy models.",