chore(itam): correct field type for Model Unit test suite for model DeviceType

ref: #920 closes #919
This commit is contained in:
2025-07-31 13:29:00 +09:30
parent 3bd673b2ae
commit 8363c50b91
3 changed files with 4 additions and 82 deletions

View File

@ -60,7 +60,7 @@ class DeviceSoftwareModelTestCases(
'action': {
'blank': True,
'default': models.fields.NOT_PROVIDED,
'field_type': models.CharField,
'field_type': models.IntegerField,
'null': True,
'unique': False,
},

View File

@ -1,78 +0,0 @@
import django
import pytest
from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
from django.shortcuts import reverse
from django.test import Client, TestCase
from access.models.tenant import Tenant as Organization
from access.models.team import Team
from access.models.team_user import TeamUsers
from api.tests.abstract.api_fields import APITenancyObject
from itam.models.device import DeviceType
User = django.contrib.auth.get_user_model()
@pytest.mark.model_devicetype
@pytest.mark.module_itam
class DeviceTypeAPI(
TestCase,
APITenancyObject
):
model = DeviceType
@classmethod
def setUpTestData(self):
"""Setup Test
1. Create an organization for user and item
2. Create an item
"""
self.organization = Organization.objects.create(name='test_org')
self.item = DeviceType.objects.create(
organization = self.organization,
name = 'computer',
model_notes = 'a note',
)
self.url_view_kwargs = {'pk': self.item.id}
view_permissions = Permission.objects.get(
codename = 'view_' + self.model._meta.model_name,
content_type = ContentType.objects.get(
app_label = self.model._meta.app_label,
model = self.model._meta.model_name,
)
)
view_team = Team.objects.create(
team_name = 'view_team',
organization = self.organization,
)
view_team.permissions.set([view_permissions])
self.view_user = User.objects.create_user(username="test_user_view", password="password")
teamuser = TeamUsers.objects.create(
team = view_team,
user = self.view_user
)
client = Client()
url = reverse('v2:_api_devicetype-detail', kwargs=self.url_view_kwargs)
client.force_login(self.view_user)
response = client.get(url)
self.api_data = response.data

View File

@ -17,7 +17,7 @@ class DeviceTypeModelTestCases(
@property
def parameterized_class_attributes(self):
return {
'model_tag': {
'type': str,
@ -28,12 +28,12 @@ class DeviceTypeModelTestCases(
@property
def parameterized_model_fields(self):
return {
'name': {
'blank': False,
'default': models.fields.NOT_PROVIDED,
'field_type': models.IntegerField,
'field_type': models.CharField,
'length': 50,
'null': False,
'unique': True,