refactor(itam): Remove old test suites no longer required model OperatingSystem
ref: #925 closes #922
This commit is contained in:
@ -10,7 +10,7 @@ from api.tests.functional.test_functional_api_fields import (
|
||||
|
||||
|
||||
|
||||
@pytest.mark.model_device
|
||||
@pytest.mark.model_operatingsystem
|
||||
class OperatingSystemAPITestCases(
|
||||
APIFieldsInheritedCases,
|
||||
):
|
||||
|
@ -19,6 +19,7 @@ User = django.contrib.auth.get_user_model()
|
||||
|
||||
|
||||
|
||||
@pytest.mark.module_itam
|
||||
class ViewSetBase:
|
||||
|
||||
model = OperatingSystem
|
||||
@ -216,6 +217,7 @@ class ViewSetBase:
|
||||
|
||||
|
||||
|
||||
@pytest.mark.module_itam
|
||||
class OperatingSystemMetadata(
|
||||
ViewSetBase,
|
||||
MetadataAttributesFunctional,
|
||||
|
@ -6,7 +6,7 @@ from core.tests.functional.centurion_abstract.test_functional_centurion_abstract
|
||||
|
||||
|
||||
|
||||
@pytest.mark.model_device
|
||||
@pytest.mark.model_operatingsystem
|
||||
class OperatingSystemModelTestCases(
|
||||
CenturionAbstractModelInheritedCases
|
||||
):
|
||||
|
@ -1,182 +0,0 @@
|
||||
import django
|
||||
import pytest
|
||||
import unittest
|
||||
|
||||
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 rest_framework.relations import Hyperlink
|
||||
|
||||
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 core.models.manufacturer import Manufacturer
|
||||
|
||||
from itam.models.operating_system import OperatingSystem
|
||||
|
||||
User = django.contrib.auth.get_user_model()
|
||||
|
||||
|
||||
|
||||
@pytest.mark.model_operatingsystem
|
||||
@pytest.mark.module_itam
|
||||
class OperatingSystemAPI(
|
||||
TestCase,
|
||||
APITenancyObject
|
||||
):
|
||||
|
||||
model = OperatingSystem
|
||||
|
||||
@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')
|
||||
|
||||
manufacturer = Manufacturer.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'a manufacturer'
|
||||
)
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'one',
|
||||
publisher = manufacturer,
|
||||
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_operatingsystem-detail', kwargs=self.url_view_kwargs)
|
||||
|
||||
|
||||
client.force_login(self.view_user)
|
||||
response = client.get(url)
|
||||
|
||||
self.api_data = response.data
|
||||
|
||||
|
||||
def test_api_field_exists_publisher(self):
|
||||
""" Test for existance of API Field
|
||||
|
||||
publisher field must exist
|
||||
"""
|
||||
|
||||
assert 'publisher' in self.api_data
|
||||
|
||||
|
||||
def test_api_field_type_publisher(self):
|
||||
""" Test for type for API Field
|
||||
|
||||
publisher field must be dict
|
||||
"""
|
||||
|
||||
assert type(self.api_data['publisher']) is dict
|
||||
|
||||
|
||||
def test_api_field_exists_publisher_id(self):
|
||||
""" Test for existance of API Field
|
||||
|
||||
publisher.id field must exist
|
||||
"""
|
||||
|
||||
assert 'id' in self.api_data['publisher']
|
||||
|
||||
|
||||
def test_api_field_type_publisher_id(self):
|
||||
""" Test for type for API Field
|
||||
|
||||
publisher.id field must be int
|
||||
"""
|
||||
|
||||
assert type(self.api_data['publisher']['id']) is int
|
||||
|
||||
|
||||
def test_api_field_exists_publisher_display_name(self):
|
||||
""" Test for existance of API Field
|
||||
|
||||
publisher.display_name field must exist
|
||||
"""
|
||||
|
||||
assert 'display_name' in self.api_data['publisher']
|
||||
|
||||
|
||||
def test_api_field_type_publisher_display_name(self):
|
||||
""" Test for type for API Field
|
||||
|
||||
publisher.display_name field must be str
|
||||
"""
|
||||
|
||||
assert type(self.api_data['publisher']['display_name']) is str
|
||||
|
||||
|
||||
def test_api_field_exists_publisher_url(self):
|
||||
""" Test for existance of API Field
|
||||
|
||||
publisher.url field must exist
|
||||
"""
|
||||
|
||||
assert 'url' in self.api_data['publisher']
|
||||
|
||||
|
||||
def test_api_field_type_publisher_url(self):
|
||||
""" Test for type for API Field
|
||||
|
||||
publisher.url field must be Hyperlink
|
||||
"""
|
||||
|
||||
assert type(self.api_data['publisher']['url']) is Hyperlink
|
||||
|
||||
|
||||
|
||||
def test_api_field_exists_urls_tickets(self):
|
||||
""" Test for existance of API Field
|
||||
|
||||
_urls.tickets field must exist
|
||||
"""
|
||||
|
||||
assert 'tickets' in self.api_data['_urls']
|
||||
|
||||
|
||||
def test_api_field_type_urls_tickets(self):
|
||||
""" Test for type for API Field
|
||||
|
||||
_urls.tickets field must be str
|
||||
"""
|
||||
|
||||
assert type(self.api_data['_urls']['tickets']) is str
|
||||
|
@ -1,99 +0,0 @@
|
||||
import pytest
|
||||
|
||||
from django.shortcuts import reverse
|
||||
from django.test import Client, TestCase
|
||||
|
||||
from core.tests.abstract.test_item_ticket_api_v2 import ItemTicketAPI
|
||||
|
||||
from core.models.ticket.ticket_linked_items import TicketLinkedItem
|
||||
|
||||
from itam.models.operating_system import OperatingSystem
|
||||
|
||||
|
||||
|
||||
@pytest.mark.skip( reason = 'this ticket model is depreciated' )
|
||||
@pytest.mark.model_operatingsystem
|
||||
@pytest.mark.module_itam
|
||||
class OperatingSystemItemTicketAPI(
|
||||
ItemTicketAPI,
|
||||
TestCase,
|
||||
):
|
||||
"""Test Cases for Item Tickets
|
||||
|
||||
Args:
|
||||
APITenancyObject (class): Base class for ALL field checks
|
||||
"""
|
||||
|
||||
item_type = TicketLinkedItem.Modules.OPERATING_SYSTEM
|
||||
|
||||
item_class = 'operating_system'
|
||||
|
||||
item_model = OperatingSystem
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
"""Setup Test
|
||||
|
||||
1. Create an organization for user and item
|
||||
2. Create an item
|
||||
|
||||
"""
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
|
||||
self.linked_item = self.item_model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'dev'
|
||||
)
|
||||
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
ticket = self.ticket,
|
||||
|
||||
# Item attributes
|
||||
|
||||
item = self.linked_item.id,
|
||||
item_type = self.item_type,
|
||||
)
|
||||
|
||||
|
||||
|
||||
self.url_view_kwargs = {
|
||||
'item_class': self.item_class,
|
||||
'item_id': self.item.id,
|
||||
'pk': self.item.id,
|
||||
}
|
||||
|
||||
|
||||
client = Client()
|
||||
url = reverse('v2:_api_v2_item_tickets-detail', kwargs=self.url_view_kwargs)
|
||||
|
||||
|
||||
client.force_login(self.view_user)
|
||||
response = client.get(url)
|
||||
|
||||
self.api_data = response.data
|
||||
|
||||
|
||||
|
||||
def test_api_field_value_item_id(self):
|
||||
""" Test for existance of API Field
|
||||
|
||||
item.id field must exist
|
||||
"""
|
||||
|
||||
assert self.api_data['item']['id'] == self.linked_item.id
|
||||
|
||||
|
||||
|
||||
def test_api_field_value_item_type(self):
|
||||
""" Test for type for API Field
|
||||
|
||||
item_type field must be int
|
||||
"""
|
||||
|
||||
assert self.api_data['item_type'] == self.item_type
|
@ -67,35 +67,3 @@ class OperatingSystemModelPyTest(
|
||||
OperatingSystemModelTestCases,
|
||||
):
|
||||
pass
|
||||
|
||||
# def test_method_get_url_kwargs(self, mocker, model_instance, model_kwargs):
|
||||
# """Test Class Method
|
||||
|
||||
# Ensure method `get_url_kwargs` returns the correct value.
|
||||
# """
|
||||
|
||||
|
||||
# url = model_instance.get_url_kwargs()
|
||||
|
||||
# assert model_instance.get_url_kwargs() == {
|
||||
# 'device_id': model_kwargs['device'].id,
|
||||
# 'pk': model_instance.id
|
||||
# }
|
||||
|
||||
|
||||
# def test_model_tag_defined(self, model):
|
||||
# """ Model Tag
|
||||
|
||||
# Ensure that the model has a tag defined.
|
||||
# """
|
||||
|
||||
# pytest.xfail( reason = 'model does not require' )
|
||||
|
||||
|
||||
# def test_method_value_not_default___str__(self, model, model_instance ):
|
||||
# """Test Method
|
||||
|
||||
# Ensure method `__str__` does not return the default value.
|
||||
# """
|
||||
|
||||
# pytest.xfail( reason = 'model does not require' )
|
||||
|
@ -1,7 +1,5 @@
|
||||
import pytest
|
||||
|
||||
# from django.db import models
|
||||
|
||||
from rest_framework.exceptions import ValidationError
|
||||
|
||||
from api.tests.unit.test_unit_serializer import (
|
||||
|
Reference in New Issue
Block a user