refactor(itam): ViewSet Unit Test Suite re-written to Pytest for model SoftwareCategory

ref: #925 #926
This commit is contained in:
2025-08-02 12:13:44 +09:30
parent 42e191ba76
commit dd337b68bc

View File

@ -1,45 +1,83 @@
import pytest
from django.test import Client, TestCase
from rest_framework.reverse import reverse
from api.tests.unit.test_unit_common_viewset import ModelViewSetInheritedCases
from itam.viewsets.software_category import ViewSet
from itam.viewsets.software_category import (
SoftwareCategory,
ViewSet,
)
@pytest.mark.skip(reason = 'see #895, tests being refactored')
@pytest.mark.model_softwarecategory
@pytest.mark.module_itam
class SoftwareCategoryViewsetList(
class ViewsetTestCases(
ModelViewSetInheritedCases,
TestCase,
):
viewset = ViewSet
route_name = 'v2:_api_softwarecategory'
@pytest.fixture( scope = 'function' )
def viewset(self):
return ViewSet
@classmethod
def setUpTestData(self):
"""Setup Test
1. make list request
"""
@property
def parameterized_class_attributes(self):
return {
'_model_documentation': {
'type': type(None),
},
'back_url': {
'type': type(None),
},
'documentation': {
'type': type(None),
'value': None
},
'filterset_fields': {
'value': [
'organization'
]
},
'model': {
'value': SoftwareCategory
},
'model_documentation': {
'type': type(None),
},
'queryset': {
'type': type(None),
},
'serializer_class': {
'type': type(None),
},
'search_fields': {
'value': [
'name'
]
},
'view_description': {
'value': 'Physical Softwares'
},
'view_name': {
'type': type(None),
},
'view_serializer_name': {
'type': type(None),
}
}
super().setUpTestData()
class SoftwareCategoryViewsetInheritedCases(
ViewsetTestCases,
):
pass
client = Client()
url = reverse(
self.route_name + '-list',
kwargs = self.kwargs
)
client.force_login(self.view_user)
@pytest.mark.module_itam
class SoftwareCategoryViewsetPyTest(
ViewsetTestCases,
):
self.http_options_response_list = client.options(url)
pass