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

@@ -3,19 +3,14 @@ from netaddr import EUI
from dcim.choices import InterfaceModeChoices
from dcim.models import DeviceRole, Interface, Platform, Site
from ipam.models import VLAN
from utilities.testing import StandardTestCases
from utilities.testing import ViewTestCases
from virtualization.choices import *
from virtualization.models import Cluster, ClusterGroup, ClusterType, VirtualMachine
class ClusterGroupTestCase(StandardTestCases.Views):
class ClusterGroupTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
model = ClusterGroup
# Disable inapplicable tests
test_get_object = None
test_delete_object = None
test_bulk_edit_objects = None
@classmethod
def setUpTestData(cls):
@@ -38,14 +33,9 @@ class ClusterGroupTestCase(StandardTestCases.Views):
)
class ClusterTypeTestCase(StandardTestCases.Views):
class ClusterTypeTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
model = ClusterType
# Disable inapplicable tests
test_get_object = None
test_delete_object = None
test_bulk_edit_objects = None
@classmethod
def setUpTestData(cls):
@@ -68,7 +58,7 @@ class ClusterTypeTestCase(StandardTestCases.Views):
)
class ClusterTestCase(StandardTestCases.Views):
class ClusterTestCase(ViewTestCases.PrimaryObjectViewTestCase):
model = Cluster
@classmethod
@@ -124,7 +114,7 @@ class ClusterTestCase(StandardTestCases.Views):
}
class VirtualMachineTestCase(StandardTestCases.Views):
class VirtualMachineTestCase(ViewTestCases.PrimaryObjectViewTestCase):
model = VirtualMachine
@classmethod
@@ -193,17 +183,16 @@ class VirtualMachineTestCase(StandardTestCases.Views):
}
class InterfaceTestCase(StandardTestCases.Views):
class InterfaceTestCase(
ViewTestCases.GetObjectViewTestCase,
ViewTestCases.DeviceComponentViewTestCase,
):
model = Interface
# Disable inapplicable tests
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)
def _get_base_url(self):
# Interface belongs to the DCIM app, so we have to override the base URL
return 'virtualization:interface_{}'