1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Establish standard test cases for all models

This commit is contained in:
Jeremy Stretch
2020-02-12 12:33:27 -05:00
parent e4b910fe87
commit 3b1128f8f3
8 changed files with 253 additions and 390 deletions

View File

@@ -11,7 +11,7 @@ from dcim.choices import *
from dcim.constants import *
from dcim.models import *
from ipam.models import VLAN
from utilities.testing import StandardTestCases
from utilities.testing import ViewTestCases
def create_test_device(name):
@@ -27,14 +27,9 @@ def create_test_device(name):
return device
class RegionTestCase(StandardTestCases.Views):
class RegionTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
model = Region
# Disable inapplicable tests
test_get_object = None
test_delete_object = None
test_bulk_edit_objects = None
@classmethod
def setUpTestData(cls):
@@ -61,7 +56,7 @@ class RegionTestCase(StandardTestCases.Views):
)
class SiteTestCase(StandardTestCases.Views):
class SiteTestCase(ViewTestCases.PrimaryObjectViewTestCase):
model = Site
@classmethod
@@ -118,14 +113,9 @@ class SiteTestCase(StandardTestCases.Views):
}
class RackGroupTestCase(StandardTestCases.Views):
class RackGroupTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
model = RackGroup
# Disable inapplicable tests
test_get_object = None
test_delete_object = None
test_bulk_edit_objects = None
@classmethod
def setUpTestData(cls):
@@ -152,14 +142,9 @@ class RackGroupTestCase(StandardTestCases.Views):
)
class RackRoleTestCase(StandardTestCases.Views):
class RackRoleTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
model = RackRole
# Disable inapplicable tests
test_get_object = None
test_delete_object = None
test_bulk_edit_objects = None
@classmethod
def setUpTestData(cls):
@@ -184,7 +169,7 @@ class RackRoleTestCase(StandardTestCases.Views):
)
class RackReservationTestCase(StandardTestCases.Views):
class RackReservationTestCase(ViewTestCases.PrimaryObjectViewTestCase):
model = RackReservation
# Disable inapplicable tests
@@ -226,7 +211,7 @@ class RackReservationTestCase(StandardTestCases.Views):
}
class RackTestCase(StandardTestCases.Views):
class RackTestCase(ViewTestCases.PrimaryObjectViewTestCase):
model = Rack
@classmethod
@@ -302,14 +287,9 @@ class RackTestCase(StandardTestCases.Views):
}
class ManufacturerTestCase(StandardTestCases.Views):
class ManufacturerTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
model = Manufacturer
# Disable inapplicable tests
test_get_object = None
test_delete_object = None
test_bulk_edit_objects = None
@classmethod
def setUpTestData(cls):
@@ -332,7 +312,7 @@ class ManufacturerTestCase(StandardTestCases.Views):
)
class DeviceTypeTestCase(StandardTestCases.Views):
class DeviceTypeTestCase(ViewTestCases.PrimaryObjectViewTestCase):
model = DeviceType
@classmethod
@@ -528,18 +508,9 @@ device-bays:
# DeviceType components
#
class ConsolePortTemplateTestCase(StandardTestCases.Views):
class ConsolePortTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCase):
model = ConsolePortTemplate
# Disable inapplicable views
test_get_object = None
test_list_objects = None
test_create_object = None
test_import_objects = None
def test_bulk_create_objects(self):
return self._test_bulk_create_objects(expected_count=3)
@classmethod
def setUpTestData(cls):
manufacturer = Manufacturer.objects.create(name='Manufacturer 1', slug='manufacturer-1')
@@ -572,18 +543,9 @@ class ConsolePortTemplateTestCase(StandardTestCases.Views):
}
class ConsoleServerPortTemplateTestCase(StandardTestCases.Views):
class ConsoleServerPortTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCase):
model = ConsoleServerPortTemplate
# Disable inapplicable views
test_get_object = None
test_list_objects = None
test_create_object = None
test_import_objects = None
def test_bulk_create_objects(self):
return self._test_bulk_create_objects(expected_count=3)
@classmethod
def setUpTestData(cls):
manufacturer = Manufacturer.objects.create(name='Manufacturer 1', slug='manufacturer-1')
@@ -616,18 +578,9 @@ class ConsoleServerPortTemplateTestCase(StandardTestCases.Views):
}
class PowerPortTemplateTestCase(StandardTestCases.Views):
class PowerPortTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCase):
model = PowerPortTemplate
# Disable inapplicable views
test_get_object = None
test_list_objects = None
test_create_object = None
test_import_objects = None
def test_bulk_create_objects(self):
return self._test_bulk_create_objects(expected_count=3)
@classmethod
def setUpTestData(cls):
manufacturer = Manufacturer.objects.create(name='Manufacturer 1', slug='manufacturer-1')
@@ -666,18 +619,9 @@ class PowerPortTemplateTestCase(StandardTestCases.Views):
}
class PowerOutletTemplateTestCase(StandardTestCases.Views):
class PowerOutletTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCase):
model = PowerOutletTemplate
# Disable inapplicable views
test_get_object = None
test_list_objects = None
test_create_object = None
test_import_objects = None
def test_bulk_create_objects(self):
return self._test_bulk_create_objects(expected_count=3)
@classmethod
def setUpTestData(cls):
manufacturer = Manufacturer.objects.create(name='Manufacturer 1', slug='manufacturer-1')
@@ -716,18 +660,9 @@ class PowerOutletTemplateTestCase(StandardTestCases.Views):
}
class InterfaceTemplateTestCase(StandardTestCases.Views):
class InterfaceTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCase):
model = InterfaceTemplate
# Disable inapplicable views
test_get_object = None
test_list_objects = None
test_create_object = None
test_import_objects = None
def test_bulk_create_objects(self):
return self._test_bulk_create_objects(expected_count=3)
@classmethod
def setUpTestData(cls):
manufacturer = Manufacturer.objects.create(name='Manufacturer 1', slug='manufacturer-1')
@@ -763,18 +698,9 @@ class InterfaceTemplateTestCase(StandardTestCases.Views):
}
class FrontPortTemplateTestCase(StandardTestCases.Views):
class FrontPortTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCase):
model = FrontPortTemplate
# Disable inapplicable views
test_get_object = None
test_list_objects = None
test_create_object = None
test_import_objects = None
def test_bulk_create_objects(self):
return self._test_bulk_create_objects(expected_count=3)
@classmethod
def setUpTestData(cls):
manufacturer = Manufacturer.objects.create(name='Manufacturer 1', slug='manufacturer-1')
@@ -818,18 +744,9 @@ class FrontPortTemplateTestCase(StandardTestCases.Views):
}
class RearPortTemplateTestCase(StandardTestCases.Views):
class RearPortTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCase):
model = RearPortTemplate
# Disable inapplicable views
test_get_object = None
test_list_objects = None
test_create_object = None
test_import_objects = None
def test_bulk_create_objects(self):
return self._test_bulk_create_objects(expected_count=3)
@classmethod
def setUpTestData(cls):
manufacturer = Manufacturer.objects.create(name='Manufacturer 1', slug='manufacturer-1')
@@ -864,19 +781,12 @@ class RearPortTemplateTestCase(StandardTestCases.Views):
}
class DeviceBayTemplateTestCase(StandardTestCases.Views):
class DeviceBayTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCase):
model = DeviceBayTemplate
# Disable inapplicable views
test_get_object = None
test_list_objects = None
test_create_object = None
test_import_objects = None
test_bulk_edit_objects = None
def test_bulk_create_objects(self):
return self._test_bulk_create_objects(expected_count=3)
@classmethod
def setUpTestData(cls):
manufacturer = Manufacturer.objects.create(name='Manufacturer 1', slug='manufacturer-1')
@@ -903,14 +813,9 @@ class DeviceBayTemplateTestCase(StandardTestCases.Views):
}
class DeviceRoleTestCase(StandardTestCases.Views):
class DeviceRoleTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
model = DeviceRole
# Disable inapplicable tests
test_get_object = None
test_delete_object = None
test_bulk_edit_objects = None
@classmethod
def setUpTestData(cls):
@@ -936,14 +841,9 @@ class DeviceRoleTestCase(StandardTestCases.Views):
)
class PlatformTestCase(StandardTestCases.Views):
class PlatformTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
model = Platform
# Disable inapplicable tests
test_get_object = None
test_delete_object = None
test_bulk_edit_objects = None
@classmethod
def setUpTestData(cls):
@@ -971,7 +871,7 @@ class PlatformTestCase(StandardTestCases.Views):
)
class DeviceTestCase(StandardTestCases.Views):
class DeviceTestCase(ViewTestCases.PrimaryObjectViewTestCase):
model = Device
@classmethod
@@ -1056,16 +956,9 @@ class DeviceTestCase(StandardTestCases.Views):
}
class ConsolePortTestCase(StandardTestCases.Views):
class ConsolePortTestCase(ViewTestCases.DeviceComponentViewTestCase):
model = ConsolePort
# Disable inapplicable views
test_get_object = None
test_create_object = None
def test_bulk_create_objects(self):
return self._test_bulk_create_objects(expected_count=3)
@classmethod
def setUpTestData(cls):
device = create_test_device('Device 1')
@@ -1105,16 +998,9 @@ class ConsolePortTestCase(StandardTestCases.Views):
)
class ConsoleServerPortTestCase(StandardTestCases.Views):
class ConsoleServerPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
model = ConsoleServerPort
# Disable inapplicable views
test_get_object = None
test_create_object = None
def test_bulk_create_objects(self):
return self._test_bulk_create_objects(expected_count=3)
@classmethod
def setUpTestData(cls):
device = create_test_device('Device 1')
@@ -1155,16 +1041,9 @@ class ConsoleServerPortTestCase(StandardTestCases.Views):
)
class PowerPortTestCase(StandardTestCases.Views):
class PowerPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
model = PowerPort
# Disable inapplicable views
test_get_object = None
test_create_object = None
def test_bulk_create_objects(self):
return self._test_bulk_create_objects(expected_count=3)
@classmethod
def setUpTestData(cls):
device = create_test_device('Device 1')
@@ -1210,16 +1089,9 @@ class PowerPortTestCase(StandardTestCases.Views):
)
class PowerOutletTestCase(StandardTestCases.Views):
class PowerOutletTestCase(ViewTestCases.DeviceComponentViewTestCase):
model = PowerOutlet
# Disable inapplicable views
test_get_object = None
test_create_object = None
def test_bulk_create_objects(self):
return self._test_bulk_create_objects(expected_count=3)
@classmethod
def setUpTestData(cls):
device = create_test_device('Device 1')
@@ -1272,15 +1144,12 @@ class PowerOutletTestCase(StandardTestCases.Views):
)
class InterfaceTestCase(StandardTestCases.Views):
class InterfaceTestCase(
ViewTestCases.GetObjectViewTestCase,
ViewTestCases.DeviceComponentViewTestCase,
):
model = Interface
# Disable inapplicable views
test_create_object = None
def test_bulk_create_objects(self):
return self._test_bulk_create_objects(expected_count=3)
@classmethod
def setUpTestData(cls):
device = create_test_device('Device 1')
@@ -1356,16 +1225,9 @@ class InterfaceTestCase(StandardTestCases.Views):
)
class FrontPortTestCase(StandardTestCases.Views):
class FrontPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
model = FrontPort
# Disable inapplicable views
test_get_object = None
test_create_object = None
def test_bulk_create_objects(self):
return self._test_bulk_create_objects(expected_count=3)
@classmethod
def setUpTestData(cls):
device = create_test_device('Device 1')
@@ -1420,16 +1282,9 @@ class FrontPortTestCase(StandardTestCases.Views):
)
class RearPortTestCase(StandardTestCases.Views):
class RearPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
model = RearPort
# Disable inapplicable views
test_get_object = None
test_create_object = None
def test_bulk_create_objects(self):
return self._test_bulk_create_objects(expected_count=3)
@classmethod
def setUpTestData(cls):
device = create_test_device('Device 1')
@@ -1471,19 +1326,12 @@ class RearPortTestCase(StandardTestCases.Views):
)
class DeviceBayTestCase(StandardTestCases.Views):
class DeviceBayTestCase(ViewTestCases.DeviceComponentViewTestCase):
model = DeviceBay
# Disable inapplicable views
test_get_object = None
test_create_object = None
# TODO
test_bulk_edit_objects = None
def test_bulk_create_objects(self):
return self._test_bulk_create_objects(expected_count=3)
@classmethod
def setUpTestData(cls):
device1 = create_test_device('Device 1')
@@ -1520,16 +1368,9 @@ class DeviceBayTestCase(StandardTestCases.Views):
)
class InventoryItemTestCase(StandardTestCases.Views):
class InventoryItemTestCase(ViewTestCases.DeviceComponentViewTestCase):
model = InventoryItem
# Disable inapplicable views
test_get_object = None
test_create_object = None
def test_bulk_create_objects(self):
return self._test_bulk_create_objects(expected_count=3)
@classmethod
def setUpTestData(cls):
device = create_test_device('Device 1')
@@ -1581,7 +1422,7 @@ class InventoryItemTestCase(StandardTestCases.Views):
)
class CableTestCase(StandardTestCases.Views):
class CableTestCase(ViewTestCases.PrimaryObjectViewTestCase):
model = Cable
# TODO: Creation URL needs termination context
@@ -1655,7 +1496,7 @@ class CableTestCase(StandardTestCases.Views):
}
class VirtualChassisTestCase(StandardTestCases.Views):
class VirtualChassisTestCase(ViewTestCases.PrimaryObjectViewTestCase):
model = VirtualChassis
# Disable inapplicable tests
@@ -1709,7 +1550,7 @@ class VirtualChassisTestCase(StandardTestCases.Views):
Device.objects.filter(pk=device6.pk).update(virtual_chassis=vc3, vc_position=2)
class PowerPanelTestCase(StandardTestCases.Views):
class PowerPanelTestCase(ViewTestCases.PrimaryObjectViewTestCase):
model = PowerPanel
# Disable inapplicable tests
@@ -1750,7 +1591,7 @@ class PowerPanelTestCase(StandardTestCases.Views):
)
class PowerFeedTestCase(StandardTestCases.Views):
class PowerFeedTestCase(ViewTestCases.PrimaryObjectViewTestCase):
model = PowerFeed
@classmethod