test(core): Add Base Centurion model Functional Test Suite
ref: #773 #767
This commit is contained in:
@ -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):
|
||||
|
||||
|
14
app/core/tests/functional/centurion_abstract/conftest.py
Normal file
14
app/core/tests/functional/centurion_abstract/conftest.py
Normal 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
|
@ -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
|
@ -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.",
|
||||
|
Reference in New Issue
Block a user