feat(models): add property parent_object to models that have a parent
!22
This commit is contained in:
@ -0,0 +1,70 @@
|
||||
import pytest
|
||||
import unittest
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models import Organization
|
||||
|
||||
from config_management.models.groups import ConfigGroups, ConfigGroupSoftware
|
||||
|
||||
from itam.models.device import Device, DeviceOperatingSystem
|
||||
from itam.models.operating_system import OperatingSystem, OperatingSystemVersion
|
||||
|
||||
|
||||
|
||||
class DeviceOperatingSystemModel(TestCase):
|
||||
|
||||
model = DeviceOperatingSystem
|
||||
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
""" Setup Test
|
||||
|
||||
"""
|
||||
|
||||
organization = Organization.objects.create(name='test_org')
|
||||
|
||||
|
||||
self.parent_item = Device.objects.create(
|
||||
organization=organization,
|
||||
name = 'device_name'
|
||||
)
|
||||
|
||||
os = OperatingSystem.objects.create(
|
||||
organization=organization,
|
||||
name = 'os_name'
|
||||
)
|
||||
|
||||
os_version = OperatingSystemVersion.objects.create(
|
||||
name = "12",
|
||||
operating_system = os,
|
||||
)
|
||||
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = organization,
|
||||
operating_system_version = os_version,
|
||||
device = self.parent_item
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
def test_model_has_property_parent_object(self):
|
||||
""" Check if model contains 'parent_object'
|
||||
|
||||
This is a required property for all models that have a parent
|
||||
"""
|
||||
|
||||
assert hasattr(self.model, 'parent_object')
|
||||
|
||||
|
||||
def test_model_property_parent_object_returns_object(self):
|
||||
""" Check if model contains 'parent_object'
|
||||
|
||||
This is a required property for all models that have a parent
|
||||
"""
|
||||
|
||||
assert self.item.parent_object == self.parent_item
|
62
app/itam/tests/device_software/test_device_software.py
Normal file
62
app/itam/tests/device_software/test_device_software.py
Normal file
@ -0,0 +1,62 @@
|
||||
import pytest
|
||||
import unittest
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models import Organization
|
||||
|
||||
from config_management.models.groups import ConfigGroups, ConfigGroupSoftware
|
||||
|
||||
from itam.models.device import Device, DeviceSoftware
|
||||
from itam.models.software import Software
|
||||
|
||||
|
||||
|
||||
class DeviceSoftwareModel(TestCase):
|
||||
|
||||
model = DeviceSoftware
|
||||
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
""" Setup Test
|
||||
|
||||
"""
|
||||
|
||||
organization = Organization.objects.create(name='test_org')
|
||||
|
||||
|
||||
self.parent_item = Device.objects.create(
|
||||
organization=organization,
|
||||
name = 'device_name'
|
||||
)
|
||||
|
||||
self.software_item = Software.objects.create(
|
||||
organization=organization,
|
||||
name = 'software_name',
|
||||
)
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
software = self.software_item,
|
||||
device = self.parent_item
|
||||
)
|
||||
|
||||
|
||||
|
||||
def test_model_has_property_parent_object(self):
|
||||
""" Check if model contains 'parent_object'
|
||||
|
||||
This is a required property for all models that have a parent
|
||||
"""
|
||||
|
||||
assert hasattr(self.model, 'parent_object')
|
||||
|
||||
|
||||
def test_model_property_parent_object_returns_object(self):
|
||||
""" Check if model contains 'parent_object'
|
||||
|
||||
This is a required property for all models that have a parent
|
||||
"""
|
||||
|
||||
assert self.item.parent_object == self.parent_item
|
@ -0,0 +1,57 @@
|
||||
import pytest
|
||||
import unittest
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from access.models import Organization
|
||||
|
||||
from config_management.models.groups import ConfigGroups, ConfigGroupSoftware
|
||||
|
||||
from itam.models.operating_system import OperatingSystem, OperatingSystemVersion
|
||||
|
||||
|
||||
|
||||
class OperatingSystemVersionModel(TestCase):
|
||||
|
||||
model = OperatingSystemVersion
|
||||
|
||||
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
""" Setup Test
|
||||
|
||||
"""
|
||||
|
||||
organization = Organization.objects.create(name='test_org')
|
||||
|
||||
|
||||
self.parent_item = OperatingSystem.objects.create(
|
||||
organization=organization,
|
||||
name = 'os_name'
|
||||
)
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
name = "12",
|
||||
operating_system = self.parent_item,
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
def test_model_has_property_parent_object(self):
|
||||
""" Check if model contains 'parent_object'
|
||||
|
||||
This is a required property for all models that have a parent
|
||||
"""
|
||||
|
||||
assert hasattr(self.model, 'parent_object')
|
||||
|
||||
|
||||
def test_model_property_parent_object_returns_object(self):
|
||||
""" Check if model contains 'parent_object'
|
||||
|
||||
This is a required property for all models that have a parent
|
||||
"""
|
||||
|
||||
assert self.item.parent_object == self.parent_item
|
Reference in New Issue
Block a user