refactor(config_management): ViewSet Test Suite re-written to pytest for model ConfigGroupSoftware
ref: #908 #907
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import pytest
|
||||
import django
|
||||
|
||||
from django.contrib.auth.models import Permission
|
||||
|
@ -72,6 +72,9 @@ class ConfigGroupSoftwareModelTestCases(
|
||||
def parameterized_class_attributes(self):
|
||||
|
||||
return {
|
||||
'_notes_enabled': {
|
||||
'value': False,
|
||||
},
|
||||
'model_tag': {
|
||||
'type': models.NOT_PROVIDED,
|
||||
'value': models.NOT_PROVIDED,
|
||||
|
@ -0,0 +1,83 @@
|
||||
import pytest
|
||||
|
||||
from api.tests.unit.test_unit_common_viewset import ModelViewSetInheritedCases
|
||||
|
||||
|
||||
from config_management.viewsets.config_group_software import (
|
||||
ConfigGroupSoftware,
|
||||
ViewSet,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@pytest.mark.model_configgroupsoftware
|
||||
class ViewsetTestCases(
|
||||
ModelViewSetInheritedCases,
|
||||
):
|
||||
|
||||
|
||||
@pytest.fixture( scope = 'function' )
|
||||
def viewset(self):
|
||||
return ViewSet
|
||||
|
||||
|
||||
@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',
|
||||
'software'
|
||||
]
|
||||
},
|
||||
'model': {
|
||||
'value': ConfigGroupSoftware
|
||||
},
|
||||
'model_documentation': {
|
||||
'type': type(None),
|
||||
},
|
||||
'queryset': {
|
||||
'type': type(None),
|
||||
},
|
||||
'serializer_class': {
|
||||
'type': type(None),
|
||||
},
|
||||
'search_fields': {
|
||||
'value': []
|
||||
},
|
||||
'view_description': {
|
||||
'value': 'Software for a config group'
|
||||
},
|
||||
'view_name': {
|
||||
'type': type(None),
|
||||
},
|
||||
'view_serializer_name': {
|
||||
'type': type(None),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
class ConfigGroupsViewsetInheritedCases(
|
||||
ViewsetTestCases,
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@pytest.mark.module_config_management
|
||||
class ConfigGroupsViewsetPyTest(
|
||||
ViewsetTestCases,
|
||||
):
|
||||
|
||||
pass
|
@ -1,52 +0,0 @@
|
||||
from django.test import Client, TestCase
|
||||
|
||||
from rest_framework.reverse import reverse
|
||||
|
||||
from api.tests.unit.test_unit_common_viewset import ModelViewSetInheritedCases
|
||||
|
||||
from config_management.models.groups import ConfigGroups
|
||||
from config_management.viewsets.config_group_software import ViewSet
|
||||
|
||||
|
||||
|
||||
@pytest.mark.skip(reason = 'see #895, tests being refactored')
|
||||
class ConfigGroupsSoftwareViewsetList(
|
||||
ModelViewSetInheritedCases,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
viewset = ViewSet
|
||||
|
||||
route_name = 'v2:_api_configgroupsoftware'
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test
|
||||
|
||||
1. make list request
|
||||
"""
|
||||
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
cg = ConfigGroups.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'cg'
|
||||
)
|
||||
|
||||
self.kwargs = {
|
||||
'config_group_id': cg.id
|
||||
}
|
||||
|
||||
|
||||
client = Client()
|
||||
|
||||
url = reverse(
|
||||
self.route_name + '-list',
|
||||
kwargs = self.kwargs
|
||||
)
|
||||
|
||||
client.force_login(self.view_user)
|
||||
|
||||
self.http_options_response_list = client.options(url)
|
Reference in New Issue
Block a user