mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Enable tests for component bulk edit views
This commit is contained in:
@ -726,7 +726,6 @@ class ConsoleServerPortTestCase(StandardTestCases.Views):
|
||||
|
||||
# TODO
|
||||
test_create_object = None
|
||||
test_bulk_edit_objects = None
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
@ -757,6 +756,12 @@ class ConsoleServerPortTestCase(StandardTestCases.Views):
|
||||
"Device 1,Console Server Port 6",
|
||||
)
|
||||
|
||||
cls.bulk_edit_data = {
|
||||
'device': device.pk,
|
||||
'type': ConsolePortTypeChoices.TYPE_RJ45,
|
||||
'description': 'New description',
|
||||
}
|
||||
|
||||
|
||||
class PowerPortTestCase(StandardTestCases.Views):
|
||||
model = PowerPort
|
||||
@ -808,7 +813,6 @@ class PowerOutletTestCase(StandardTestCases.Views):
|
||||
|
||||
# TODO
|
||||
test_create_object = None
|
||||
test_bulk_edit_objects = None
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
@ -847,23 +851,32 @@ class PowerOutletTestCase(StandardTestCases.Views):
|
||||
"Device 1,Power Outlet 6",
|
||||
)
|
||||
|
||||
cls.bulk_edit_data = {
|
||||
'device': device.pk,
|
||||
'type': PowerOutletTypeChoices.TYPE_IEC_C13,
|
||||
'power_port': powerports[1].pk,
|
||||
'feed_leg': PowerOutletFeedLegChoices.FEED_LEG_B,
|
||||
'description': 'New description',
|
||||
}
|
||||
|
||||
|
||||
class InterfaceTestCase(StandardTestCases.Views):
|
||||
model = Interface
|
||||
|
||||
# TODO
|
||||
test_create_object = None
|
||||
test_bulk_edit_objects = None
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
device = create_test_device('Device 1')
|
||||
|
||||
Interface.objects.bulk_create([
|
||||
interfaces = (
|
||||
Interface(device=device, name='Interface 1'),
|
||||
Interface(device=device, name='Interface 2'),
|
||||
Interface(device=device, name='Interface 3'),
|
||||
])
|
||||
Interface(device=device, name='LAG', type=InterfaceTypeChoices.TYPE_LAG),
|
||||
)
|
||||
Interface.objects.bulk_create(interfaces)
|
||||
|
||||
vlans = (
|
||||
VLAN(vid=1, name='VLAN1', site=device.site),
|
||||
@ -879,11 +892,11 @@ class InterfaceTestCase(StandardTestCases.Views):
|
||||
'name': 'Interface X',
|
||||
'type': InterfaceTypeChoices.TYPE_1GE_GBIC,
|
||||
'enabled': False,
|
||||
'lag': None,
|
||||
'lag': interfaces[3].pk,
|
||||
'mac_address': EUI('01:02:03:04:05:06'),
|
||||
'mtu': 2000,
|
||||
'mgmt_only': True,
|
||||
'description': 'New description',
|
||||
'description': 'A front port',
|
||||
'mode': InterfaceModeChoices.MODE_TAGGED,
|
||||
'untagged_vlan': vlans[0].pk,
|
||||
'tagged_vlans': [v.pk for v in vlans[1:4]],
|
||||
@ -901,6 +914,20 @@ class InterfaceTestCase(StandardTestCases.Views):
|
||||
"Device 1,Interface 6,1000BASE-T (1GE)",
|
||||
)
|
||||
|
||||
cls.bulk_edit_data = {
|
||||
'device': device.pk,
|
||||
'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': 'New description',
|
||||
'mode': InterfaceModeChoices.MODE_TAGGED,
|
||||
'untagged_vlan': vlans[0].pk,
|
||||
'tagged_vlans': [v.pk for v in vlans[1:4]],
|
||||
}
|
||||
|
||||
|
||||
class FrontPortTestCase(StandardTestCases.Views):
|
||||
model = FrontPort
|
||||
@ -910,7 +937,6 @@ class FrontPortTestCase(StandardTestCases.Views):
|
||||
|
||||
# TODO
|
||||
test_create_object = None
|
||||
test_bulk_edit_objects = None
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
@ -952,6 +978,11 @@ class FrontPortTestCase(StandardTestCases.Views):
|
||||
"Device 1,Front Port 6,8P8C,Rear Port 6,1",
|
||||
)
|
||||
|
||||
cls.bulk_edit_data = {
|
||||
'type': PortTypeChoices.TYPE_8P8C,
|
||||
'description': 'New description',
|
||||
}
|
||||
|
||||
|
||||
class RearPortTestCase(StandardTestCases.Views):
|
||||
model = RearPort
|
||||
@ -961,7 +992,6 @@ class RearPortTestCase(StandardTestCases.Views):
|
||||
|
||||
# TODO
|
||||
test_create_object = None
|
||||
test_bulk_edit_objects = None
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
@ -978,7 +1008,7 @@ class RearPortTestCase(StandardTestCases.Views):
|
||||
'name': 'Rear Port X',
|
||||
'type': PortTypeChoices.TYPE_8P8C,
|
||||
'positions': 3,
|
||||
'description': 'New description',
|
||||
'description': 'A rear port',
|
||||
'tags': 'Alpha,Bravo,Charlie',
|
||||
|
||||
# Extraneous model fields
|
||||
@ -992,6 +1022,11 @@ class RearPortTestCase(StandardTestCases.Views):
|
||||
"Device 1,Rear Port 6,8P8C,1",
|
||||
)
|
||||
|
||||
cls.bulk_edit_data = {
|
||||
'type': PortTypeChoices.TYPE_8P8C,
|
||||
'description': 'New description',
|
||||
}
|
||||
|
||||
|
||||
class DeviceBayTestCase(StandardTestCases.Views):
|
||||
model = DeviceBay
|
||||
|
@ -270,7 +270,8 @@ class StandardTestCases:
|
||||
|
||||
@override_settings(EXEMPT_VIEW_PERMISSIONS=[])
|
||||
def test_bulk_edit_objects(self):
|
||||
pk_list = self.model.objects.values_list('pk', flat=True)
|
||||
# Bulk edit the first three objects only
|
||||
pk_list = self.model.objects.values_list('pk', flat=True)[:3]
|
||||
|
||||
request = {
|
||||
'path': self._get_url('bulk_edit'),
|
||||
|
@ -202,7 +202,6 @@ class InterfaceTestCase(StandardTestCases.Views):
|
||||
|
||||
# TODO
|
||||
test_create_object = None
|
||||
test_bulk_edit_objects = None
|
||||
|
||||
def _get_base_url(self):
|
||||
# Interface belongs to the DCIM app, so we have to override the base URL
|
||||
@ -222,9 +221,9 @@ class InterfaceTestCase(StandardTestCases.Views):
|
||||
VirtualMachine.objects.bulk_create(virtualmachines)
|
||||
|
||||
Interface.objects.bulk_create([
|
||||
Interface(virtual_machine=virtualmachines[0], name='Interface 1'),
|
||||
Interface(virtual_machine=virtualmachines[0], name='Interface 2'),
|
||||
Interface(virtual_machine=virtualmachines[0], name='Interface 3'),
|
||||
Interface(virtual_machine=virtualmachines[0], name='Interface 1', type=InterfaceTypeChoices.TYPE_VIRTUAL),
|
||||
Interface(virtual_machine=virtualmachines[0], name='Interface 2', type=InterfaceTypeChoices.TYPE_VIRTUAL),
|
||||
Interface(virtual_machine=virtualmachines[0], name='Interface 3', type=InterfaceTypeChoices.TYPE_VIRTUAL),
|
||||
])
|
||||
|
||||
vlans = (
|
||||
@ -262,3 +261,13 @@ class InterfaceTestCase(StandardTestCases.Views):
|
||||
"Device 1,Interface 5,1000BASE-T (1GE)",
|
||||
"Device 1,Interface 6,1000BASE-T (1GE)",
|
||||
)
|
||||
|
||||
cls.bulk_edit_data = {
|
||||
'virtual_machine': virtualmachines[1].pk,
|
||||
'enabled': False,
|
||||
'mtu': 2000,
|
||||
'description': 'New description',
|
||||
'mode': InterfaceModeChoices.MODE_TAGGED,
|
||||
# 'untagged_vlan': vlans[0].pk,
|
||||
# 'tagged_vlans': [v.pk for v in vlans[1:4]],
|
||||
}
|
||||
|
@ -353,7 +353,6 @@ class InterfaceDeleteView(PermissionRequiredMixin, ObjectDeleteView):
|
||||
class InterfaceBulkEditView(PermissionRequiredMixin, BulkEditView):
|
||||
permission_required = 'dcim.change_interface'
|
||||
queryset = Interface.objects.all()
|
||||
parent_model = VirtualMachine
|
||||
table = tables.InterfaceTable
|
||||
form = forms.InterfaceBulkEditForm
|
||||
|
||||
@ -361,7 +360,6 @@ class InterfaceBulkEditView(PermissionRequiredMixin, BulkEditView):
|
||||
class InterfaceBulkDeleteView(PermissionRequiredMixin, BulkDeleteView):
|
||||
permission_required = 'dcim.delete_interface'
|
||||
queryset = Interface.objects.all()
|
||||
parent_model = VirtualMachine
|
||||
table = tables.InterfaceTable
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user