refactor(itam): Updated Unit model test suite for DeviceType model

ref:#817 closes #803
This commit is contained in:
2025-06-11 17:13:02 +09:30
parent b5de17441b
commit 281e233a7a
5 changed files with 89 additions and 17 deletions

View File

@ -0,0 +1,19 @@
import pytest
@pytest.fixture( scope = 'class')
def model(model_devicetype):
yield model_devicetype
@pytest.fixture( scope = 'class', autouse = True)
def model_kwargs(request, kwargs_devicetype):
request.cls.kwargs_create_item = kwargs_devicetype.copy()
yield kwargs_devicetype.copy()
if hasattr(request.cls, 'kwargs_create_item'):
del request.cls.kwargs_create_item

View File

@ -1,6 +1,5 @@
import django
import pytest
import unittest
from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
@ -19,6 +18,8 @@ User = django.contrib.auth.get_user_model()
@pytest.mark.model_devicetype
@pytest.mark.module_itam
class DeviceTypeAPI(
TestCase,
APITenancyObject

View File

@ -0,0 +1,63 @@
import pytest
from django.db import models
from core.tests.unit.centurion_abstract.test_unit_centurion_abstract_model import (
CenturionAbstractModelInheritedCases
)
@pytest.mark.model_devicetype
class DeviceTypeModelTestCases(
CenturionAbstractModelInheritedCases
):
@property
def parameterized_class_attributes(self):
return {
'model_tag': {
'type': str,
'value': 'device_type'
},
}
@property
def parameterized_model_fields(self):
return {
'name': {
'blank': False,
'default': models.fields.NOT_PROVIDED,
'field_type': models.IntegerField,
'length': 50,
'null': False,
'unique': True,
},
'modified': {
'blank': False,
'default': models.fields.NOT_PROVIDED,
'field_type': models.DateTimeField,
'null': False,
'unique': False,
},
}
class DeviceTypeModelInheritedCases(
DeviceTypeModelTestCases,
):
pass
@pytest.mark.module_itam
class DeviceTypeModelPyTest(
DeviceTypeModelTestCases,
):
pass

View File

@ -1,3 +1,5 @@
import pytest
from django.test import Client, TestCase
from rest_framework.reverse import reverse
@ -8,6 +10,8 @@ from itam.viewsets.device_type import ViewSet
@pytest.mark.model_devicetype
@pytest.mark.module_itam
class DeviceTYpeViewsetList(
ModelViewSetInheritedCases,
TestCase,
@ -30,7 +34,7 @@ class DeviceTYpeViewsetList(
client = Client()
url = reverse(
self.route_name + '-list',
kwargs = self.kwargs

View File

@ -1,15 +0,0 @@
from django.test import TestCase
from centurion.tests.unit.test_unit_models import (
TenancyObjectInheritedCases
)
from itam.models.device import DeviceType
class DeviceTypeModel(
TenancyObjectInheritedCases,
TestCase,
):
model = DeviceType