refactor(project_management): ViewSet Unit Test Suite re-written to Pytest for model Project

ref: #938 #934
This commit is contained in:
2025-08-04 14:20:07 +09:30
parent 91082b205d
commit 187f82feaf

View File

@ -1,46 +1,88 @@
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 project_management.viewsets.project import ViewSet
from project_management.viewsets.project import (
Project,
ViewSet,
)
@pytest.mark.skip(reason = 'see #895, tests being refactored')
@pytest.mark.model_project
@pytest.mark.module_project_management
class ProjectViewsetList(
class ViewsetTestCases(
ModelViewSetInheritedCases,
TestCase,
):
viewset = ViewSet
route_name = 'v2:_api_project'
@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',
'external_system',
'priority',
'project_type',
'state'
]
},
'model': {
'value': Project
},
'model_documentation': {
'type': type(None),
},
'queryset': {
'type': type(None),
},
'serializer_class': {
'type': type(None),
},
'search_fields': {
'value': [
'name',
'description'
]
},
'view_description': {
'value': 'Physical Devices'
},
'view_name': {
'type': type(None),
},
'view_serializer_name': {
'type': type(None),
}
}
super().setUpTestData()
class ProjectViewsetInheritedCases(
ViewsetTestCases,
):
pass
client = Client()
url = reverse(
self.route_name + '-list',
kwargs = self.kwargs
)
@pytest.mark.module_project_management
class ProjectViewsetPyTest(
ViewsetTestCases,
):
client.force_login(self.view_user)
self.http_options_response_list = client.options(url)
pass