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

Enable bulk creation tests for device components

This commit is contained in:
Jeremy Stretch
2020-02-05 15:22:57 -05:00
parent 75906f7591
commit 0ad613e6b4
5 changed files with 194 additions and 8 deletions

View File

@@ -682,10 +682,11 @@ class ConsolePortTestCase(StandardTestCases.Views):
# Disable inapplicable views
test_get_object = None
test_create_object = None
test_bulk_edit_objects = None
# TODO
test_create_object = None
def test_bulk_create_objects(self):
return self._test_bulk_create_objects(expected_count=3)
@classmethod
def setUpTestData(cls):
@@ -717,6 +718,14 @@ class ConsolePortTestCase(StandardTestCases.Views):
"Device 1,Console Port 6",
)
cls.bulk_create_data = {
'device': device.pk,
'name_pattern': 'Console Port [4-6]',
'type': ConsolePortTypeChoices.TYPE_RJ45,
'description': 'A console port',
'tags': 'Alpha,Bravo,Charlie',
}
class ConsoleServerPortTestCase(StandardTestCases.Views):
model = ConsoleServerPort
@@ -727,6 +736,9 @@ class ConsoleServerPortTestCase(StandardTestCases.Views):
# TODO
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')
@@ -756,6 +768,14 @@ class ConsoleServerPortTestCase(StandardTestCases.Views):
"Device 1,Console Server Port 6",
)
cls.bulk_create_data = {
'device': device.pk,
'name_pattern': 'Console Server Port [4-6]',
'type': ConsolePortTypeChoices.TYPE_RJ45,
'description': 'A console server port',
'tags': 'Alpha,Bravo,Charlie',
}
cls.bulk_edit_data = {
'device': device.pk,
'type': ConsolePortTypeChoices.TYPE_RJ45,
@@ -773,6 +793,9 @@ class PowerPortTestCase(StandardTestCases.Views):
# TODO
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')
@@ -804,6 +827,16 @@ class PowerPortTestCase(StandardTestCases.Views):
"Device 1,Power Port 6",
)
cls.bulk_create_data = {
'device': device.pk,
'name_pattern': 'Power Port [4-6]]',
'type': PowerPortTypeChoices.TYPE_IEC_C14,
'maximum_draw': 100,
'allocated_draw': 50,
'description': 'A power port',
'tags': 'Alpha,Bravo,Charlie',
}
class PowerOutletTestCase(StandardTestCases.Views):
model = PowerOutlet
@@ -814,6 +847,9 @@ class PowerOutletTestCase(StandardTestCases.Views):
# TODO
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')
@@ -851,6 +887,16 @@ class PowerOutletTestCase(StandardTestCases.Views):
"Device 1,Power Outlet 6",
)
cls.bulk_create_data = {
'device': device.pk,
'name_pattern': 'Power Outlet [4-6]',
'type': PowerOutletTypeChoices.TYPE_IEC_C13,
'power_port': powerports[1].pk,
'feed_leg': PowerOutletFeedLegChoices.FEED_LEG_B,
'description': 'A power outlet',
'tags': 'Alpha,Bravo,Charlie',
}
cls.bulk_edit_data = {
'device': device.pk,
'type': PowerOutletTypeChoices.TYPE_IEC_C13,
@@ -866,6 +912,9 @@ class InterfaceTestCase(StandardTestCases.Views):
# TODO
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')
@@ -914,6 +963,22 @@ class InterfaceTestCase(StandardTestCases.Views):
"Device 1,Interface 6,1000BASE-T (1GE)",
)
cls.bulk_create_data = {
'device': device.pk,
'name_pattern': 'Interface [4-6]',
'type': InterfaceTypeChoices.TYPE_1GE_GBIC,
'enabled': False,
'lag': interfaces[3].pk,
'mac_address': EUI('01:02:03:04:05:06'),
'mtu': 2000,
'mgmt_only': True,
'description': 'A front port',
'mode': InterfaceModeChoices.MODE_TAGGED,
'untagged_vlan': vlans[0].pk,
'tagged_vlans': [v.pk for v in vlans[1:4]],
'tags': 'Alpha,Bravo,Charlie',
}
cls.bulk_edit_data = {
'device': device.pk,
'type': InterfaceTypeChoices.TYPE_1GE_GBIC,
@@ -938,6 +1003,9 @@ class FrontPortTestCase(StandardTestCases.Views):
# TODO
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')
@@ -978,6 +1046,17 @@ class FrontPortTestCase(StandardTestCases.Views):
"Device 1,Front Port 6,8P8C,Rear Port 6,1",
)
cls.bulk_create_data = {
'device': device.pk,
'name_pattern': 'Front Port [4-6]',
'type': PortTypeChoices.TYPE_8P8C,
'rear_port_set': [
'{}:1'.format(rp.pk) for rp in rearports[3:6]
],
'description': 'New description',
'tags': 'Alpha,Bravo,Charlie',
}
cls.bulk_edit_data = {
'type': PortTypeChoices.TYPE_8P8C,
'description': 'New description',
@@ -993,6 +1072,9 @@ class RearPortTestCase(StandardTestCases.Views):
# TODO
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')
@@ -1022,6 +1104,15 @@ class RearPortTestCase(StandardTestCases.Views):
"Device 1,Rear Port 6,8P8C,1",
)
cls.bulk_create_data = {
'device': device.pk,
'name_pattern': 'Rear Port [4-6]',
'type': PortTypeChoices.TYPE_8P8C,
'positions': 3,
'description': 'A rear port',
'tags': 'Alpha,Bravo,Charlie',
}
cls.bulk_edit_data = {
'type': PortTypeChoices.TYPE_8P8C,
'description': 'New description',
@@ -1033,11 +1124,14 @@ class DeviceBayTestCase(StandardTestCases.Views):
# Disable inapplicable views
test_get_object = None
test_create_object = None
# TODO
test_create_object = 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):
device1 = create_test_device('Device 1')
@@ -1069,6 +1163,13 @@ class DeviceBayTestCase(StandardTestCases.Views):
"Device 1,Device Bay 6",
)
cls.bulk_create_data = {
'device': device2.pk,
'name_pattern': 'Device Bay [4-6]',
'description': 'A device bay',
'tags': 'Alpha,Bravo,Charlie',
}
class InventoryItemTestCase(StandardTestCases.Views):
model = InventoryItem