diff --git a/netbox/dcim/models/device_component_templates.py b/netbox/dcim/models/device_component_templates.py
index ddd4d2426..b4f057711 100644
--- a/netbox/dcim/models/device_component_templates.py
+++ b/netbox/dcim/models/device_component_templates.py
@@ -311,7 +311,9 @@ class PowerPortTemplate(ModularComponentTemplateModel):
if self.maximum_draw is not None and self.allocated_draw is not None:
if self.allocated_draw > self.maximum_draw:
raise ValidationError({
- 'allocated_draw': _("Allocated draw cannot exceed the maximum draw ({maximum_draw}W).").format(maximum_draw=self.maximum_draw)
+ 'allocated_draw': _(
+ "Allocated draw cannot exceed the maximum draw ({maximum_draw}W)."
+ ).format(maximum_draw=self.maximum_draw)
})
def to_yaml(self):
@@ -365,11 +367,15 @@ class PowerOutletTemplate(ModularComponentTemplateModel):
if self.power_port:
if self.device_type and self.power_port.device_type != self.device_type:
raise ValidationError(
- _("Parent power port ({power_port}) must belong to the same device type").format(power_port=self.power_port)
+ _("Parent power port ({power_port}) must belong to the same device type").format(
+ power_port=self.power_port
+ )
)
if self.module_type and self.power_port.module_type != self.module_type:
raise ValidationError(
- _("Parent power port ({power_port}) must belong to the same module type").format(power_port=self.power_port)
+ _("Parent power port ({power_port}) must belong to the same module type").format(
+ power_port=self.power_port
+ )
)
def instantiate(self, **kwargs):
@@ -467,11 +473,15 @@ class InterfaceTemplate(ModularComponentTemplateModel):
raise ValidationError({'bridge': _("An interface cannot be bridged to itself.")})
if self.device_type and self.device_type != self.bridge.device_type:
raise ValidationError({
- 'bridge': _("Bridge interface ({bridge}) must belong to the same device type").format(bridge=self.bridge)
+ 'bridge': _(
+ "Bridge interface ({bridge}) must belong to the same device type"
+ ).format(bridge=self.bridge)
})
if self.module_type and self.module_type != self.bridge.module_type:
raise ValidationError({
- 'bridge': _("Bridge interface ({bridge}) must belong to the same module type").format(bridge=self.bridge)
+ 'bridge': _(
+ "Bridge interface ({bridge}) must belong to the same module type"
+ ).format(bridge=self.bridge)
})
if self.rf_role and self.type not in WIRELESS_IFACE_TYPES:
@@ -714,7 +724,9 @@ class DeviceBayTemplate(ComponentTemplateModel):
def clean(self):
if self.device_type and self.device_type.subdevice_role != SubdeviceRoleChoices.ROLE_PARENT:
raise ValidationError(
- _("Subdevice role of device type ({device_type}) must be set to \"parent\" to allow device bays.").format(device_type=self.device_type)
+ _(
+ 'Subdevice role of device type ({device_type}) must be set to "parent" to allow device bays.'
+ ).format(device_type=self.device_type)
)
def to_yaml(self):
diff --git a/netbox/dcim/models/devices.py b/netbox/dcim/models/devices.py
index b49d680a3..49034c604 100644
--- a/netbox/dcim/models/devices.py
+++ b/netbox/dcim/models/devices.py
@@ -532,7 +532,10 @@ def update_interface_bridges(device, interface_templates, module=None):
interface = Interface.objects.get(device=device, name=interface_template.resolve_name(module=module))
if interface_template.bridge:
- interface.bridge = Interface.objects.get(device=device, name=interface_template.bridge.resolve_name(module=module))
+ interface.bridge = Interface.objects.get(
+ device=device,
+ name=interface_template.bridge.resolve_name(module=module)
+ )
interface.full_clean()
interface.save()
@@ -978,9 +981,10 @@ class Device(
if hasattr(self, 'vc_master_for') and self.vc_master_for and self.vc_master_for != self.virtual_chassis:
raise ValidationError({
- 'virtual_chassis': _('Device cannot be removed from virtual chassis {virtual_chassis} because it is currently designated as its master.').format(
- virtual_chassis=self.vc_master_for
- )
+ 'virtual_chassis': _(
+ 'Device cannot be removed from virtual chassis {virtual_chassis} because it is currently '
+ 'designated as its master.'
+ ).format(virtual_chassis=self.vc_master_for)
})
def _instantiate_components(self, queryset, bulk_create=True):
diff --git a/netbox/dcim/models/racks.py b/netbox/dcim/models/racks.py
index 08b7f5a35..78eb0ea4a 100644
--- a/netbox/dcim/models/racks.py
+++ b/netbox/dcim/models/racks.py
@@ -379,7 +379,9 @@ class Rack(ContactsMixin, ImageAttachmentsMixin, RackBase):
min_height = top_device.position + top_device.device_type.u_height - self.starting_unit
if self.u_height < min_height:
raise ValidationError({
- 'u_height': _("Rack must be at least {min_height}U tall to house currently installed devices.").format(min_height=min_height)
+ 'u_height': _(
+ "Rack must be at least {min_height}U tall to house currently installed devices."
+ ).format(min_height=min_height)
})
# Validate that the Rack's starting unit is less than or equal to the position of the lowest mounted Device
diff --git a/netbox/dcim/tables/devices.py b/netbox/dcim/tables/devices.py
index 494d83114..59d0845d5 100644
--- a/netbox/dcim/tables/devices.py
+++ b/netbox/dcim/tables/devices.py
@@ -391,7 +391,8 @@ class ConsolePortTable(ModularDeviceComponentTable, PathEndpointTable):
model = models.ConsolePort
fields = (
'pk', 'id', 'name', 'device', 'module_bay', 'module', 'label', 'type', 'speed', 'description',
- 'mark_connected', 'cable', 'cable_color', 'link_peer', 'connection', 'inventory_items', 'tags', 'created', 'last_updated',
+ 'mark_connected', 'cable', 'cable_color', 'link_peer', 'connection', 'inventory_items', 'tags', 'created',
+ 'last_updated',
)
default_columns = ('pk', 'name', 'device', 'label', 'type', 'speed', 'description')
@@ -431,7 +432,8 @@ class ConsoleServerPortTable(ModularDeviceComponentTable, PathEndpointTable):
model = models.ConsoleServerPort
fields = (
'pk', 'id', 'name', 'device', 'module_bay', 'module', 'label', 'type', 'speed', 'description',
- 'mark_connected', 'cable', 'cable_color', 'link_peer', 'connection', 'inventory_items', 'tags', 'created', 'last_updated',
+ 'mark_connected', 'cable', 'cable_color', 'link_peer', 'connection', 'inventory_items', 'tags', 'created',
+ 'last_updated',
)
default_columns = ('pk', 'name', 'device', 'label', 'type', 'speed', 'description')
@@ -987,8 +989,8 @@ class InventoryItemTable(DeviceComponentTable):
class Meta(NetBoxTable.Meta):
model = models.InventoryItem
fields = (
- 'pk', 'id', 'name', 'device', 'parent', 'component', 'label', 'status', 'role', 'manufacturer', 'part_id', 'serial',
- 'asset_tag', 'description', 'discovered', 'tags', 'created', 'last_updated',
+ 'pk', 'id', 'name', 'device', 'parent', 'component', 'label', 'status', 'role', 'manufacturer', 'part_id',
+ 'serial', 'asset_tag', 'description', 'discovered', 'tags', 'created', 'last_updated',
)
default_columns = (
'pk', 'name', 'device', 'label', 'status', 'role', 'manufacturer', 'part_id', 'serial', 'asset_tag',
@@ -1006,8 +1008,8 @@ class DeviceInventoryItemTable(InventoryItemTable):
class Meta(NetBoxTable.Meta):
model = models.InventoryItem
fields = (
- 'pk', 'id', 'name', 'label', 'status', 'role', 'manufacturer', 'part_id', 'serial', 'asset_tag', 'component',
- 'description', 'discovered', 'tags', 'actions',
+ 'pk', 'id', 'name', 'label', 'status', 'role', 'manufacturer', 'part_id', 'serial', 'asset_tag',
+ 'component', 'description', 'discovered', 'tags', 'actions',
)
default_columns = (
'pk', 'name', 'label', 'status', 'role', 'manufacturer', 'part_id', 'serial', 'asset_tag', 'component',
diff --git a/netbox/dcim/tests/test_api.py b/netbox/dcim/tests/test_api.py
index f78722b67..c273e02dd 100644
--- a/netbox/dcim/tests/test_api.py
+++ b/netbox/dcim/tests/test_api.py
@@ -205,13 +205,41 @@ class LocationTest(APIViewTestCases.APIViewTestCase):
Site.objects.bulk_create(sites)
parent_locations = (
- Location.objects.create(site=sites[0], name='Parent Location 1', slug='parent-location-1', status=LocationStatusChoices.STATUS_ACTIVE),
- Location.objects.create(site=sites[1], name='Parent Location 2', slug='parent-location-2', status=LocationStatusChoices.STATUS_ACTIVE),
+ Location.objects.create(
+ site=sites[0],
+ name='Parent Location 1',
+ slug='parent-location-1',
+ status=LocationStatusChoices.STATUS_ACTIVE,
+ ),
+ Location.objects.create(
+ site=sites[1],
+ name='Parent Location 2',
+ slug='parent-location-2',
+ status=LocationStatusChoices.STATUS_ACTIVE,
+ ),
)
- Location.objects.create(site=sites[0], name='Location 1', slug='location-1', parent=parent_locations[0], status=LocationStatusChoices.STATUS_ACTIVE)
- Location.objects.create(site=sites[0], name='Location 2', slug='location-2', parent=parent_locations[0], status=LocationStatusChoices.STATUS_ACTIVE)
- Location.objects.create(site=sites[0], name='Location 3', slug='location-3', parent=parent_locations[0], status=LocationStatusChoices.STATUS_ACTIVE)
+ Location.objects.create(
+ site=sites[0],
+ name='Location 1',
+ slug='location-1',
+ parent=parent_locations[0],
+ status=LocationStatusChoices.STATUS_ACTIVE,
+ )
+ Location.objects.create(
+ site=sites[0],
+ name='Location 2',
+ slug='location-2',
+ parent=parent_locations[0],
+ status=LocationStatusChoices.STATUS_ACTIVE,
+ )
+ Location.objects.create(
+ site=sites[0],
+ name='Location 3',
+ slug='location-3',
+ parent=parent_locations[0],
+ status=LocationStatusChoices.STATUS_ACTIVE,
+ )
cls.create_data = [
{
@@ -290,9 +318,24 @@ class RackTypeTest(APIViewTestCases.APIViewTestCase):
Manufacturer.objects.bulk_create(manufacturers)
rack_types = (
- RackType(manufacturer=manufacturers[0], model='Rack Type 1', slug='rack-type-1', form_factor=RackFormFactorChoices.TYPE_CABINET,),
- RackType(manufacturer=manufacturers[0], model='Rack Type 2', slug='rack-type-2', form_factor=RackFormFactorChoices.TYPE_CABINET,),
- RackType(manufacturer=manufacturers[0], model='Rack Type 3', slug='rack-type-3', form_factor=RackFormFactorChoices.TYPE_CABINET,),
+ RackType(
+ manufacturer=manufacturers[0],
+ model='Rack Type 1',
+ slug='rack-type-1',
+ form_factor=RackFormFactorChoices.TYPE_CABINET,
+ ),
+ RackType(
+ manufacturer=manufacturers[0],
+ model='Rack Type 2',
+ slug='rack-type-2',
+ form_factor=RackFormFactorChoices.TYPE_CABINET,
+ ),
+ RackType(
+ manufacturer=manufacturers[0],
+ model='Rack Type 3',
+ slug='rack-type-3',
+ form_factor=RackFormFactorChoices.TYPE_CABINET,
+ ),
)
RackType.objects.bulk_create(rack_types)
@@ -1050,10 +1093,18 @@ class InventoryItemTemplateTest(APIViewTestCases.APIViewTestCase):
role = InventoryItemRole.objects.create(name='Inventory Item Role 1', slug='inventory-item-role-1')
inventory_item_templates = (
- InventoryItemTemplate(device_type=devicetype, name='Inventory Item Template 1', manufacturer=manufacturer, role=role),
- InventoryItemTemplate(device_type=devicetype, name='Inventory Item Template 2', manufacturer=manufacturer, role=role),
- InventoryItemTemplate(device_type=devicetype, name='Inventory Item Template 3', manufacturer=manufacturer, role=role),
- InventoryItemTemplate(device_type=devicetype, name='Inventory Item Template 4', manufacturer=manufacturer, role=role),
+ InventoryItemTemplate(
+ device_type=devicetype, name='Inventory Item Template 1', manufacturer=manufacturer, role=role
+ ),
+ InventoryItemTemplate(
+ device_type=devicetype, name='Inventory Item Template 2', manufacturer=manufacturer, role=role
+ ),
+ InventoryItemTemplate(
+ device_type=devicetype, name='Inventory Item Template 3', manufacturer=manufacturer, role=role
+ ),
+ InventoryItemTemplate(
+ device_type=devicetype, name='Inventory Item Template 4', manufacturer=manufacturer, role=role
+ ),
)
for item in inventory_item_templates:
item.save()
@@ -1961,9 +2012,15 @@ class InventoryItemTest(APIViewTestCases.APIViewTestCase):
)
Interface.objects.bulk_create(interfaces)
- InventoryItem.objects.create(device=device, name='Inventory Item 1', role=roles[0], manufacturer=manufacturer, component=interfaces[0])
- InventoryItem.objects.create(device=device, name='Inventory Item 2', role=roles[0], manufacturer=manufacturer, component=interfaces[1])
- InventoryItem.objects.create(device=device, name='Inventory Item 3', role=roles[0], manufacturer=manufacturer, component=interfaces[2])
+ InventoryItem.objects.create(
+ device=device, name='Inventory Item 1', role=roles[0], manufacturer=manufacturer, component=interfaces[0]
+ )
+ InventoryItem.objects.create(
+ device=device, name='Inventory Item 2', role=roles[0], manufacturer=manufacturer, component=interfaces[1]
+ )
+ InventoryItem.objects.create(
+ device=device, name='Inventory Item 3', role=roles[0], manufacturer=manufacturer, component=interfaces[2]
+ )
cls.create_data = [
{
diff --git a/netbox/dcim/tests/test_cablepaths.py b/netbox/dcim/tests/test_cablepaths.py
index b504d389a..1acc9a8a1 100644
--- a/netbox/dcim/tests/test_cablepaths.py
+++ b/netbox/dcim/tests/test_cablepaths.py
@@ -661,24 +661,64 @@ class CablePathTestCase(TestCase):
)
cable5.save()
path1 = self.assertPathExists(
- ([interface1, interface2], cable1, frontport1_1, rearport1, cable3, rearport2, frontport2_1, cable4, [interface5, interface6]),
+ (
+ [interface1, interface2],
+ cable1,
+ frontport1_1,
+ rearport1,
+ cable3,
+ rearport2,
+ frontport2_1,
+ cable4,
+ [interface5, interface6],
+ ),
is_complete=True,
- is_active=True
+ is_active=True,
)
path2 = self.assertPathExists(
- ([interface3, interface4], cable2, frontport1_2, rearport1, cable3, rearport2, frontport2_2, cable5, [interface7, interface8]),
+ (
+ [interface3, interface4],
+ cable2,
+ frontport1_2,
+ rearport1,
+ cable3,
+ rearport2,
+ frontport2_2,
+ cable5,
+ [interface7, interface8],
+ ),
is_complete=True,
- is_active=True
+ is_active=True,
)
path3 = self.assertPathExists(
- ([interface5, interface6], cable4, frontport2_1, rearport2, cable3, rearport1, frontport1_1, cable1, [interface1, interface2]),
+ (
+ [interface5, interface6],
+ cable4,
+ frontport2_1,
+ rearport2,
+ cable3,
+ rearport1,
+ frontport1_1,
+ cable1,
+ [interface1, interface2],
+ ),
is_complete=True,
- is_active=True
+ is_active=True,
)
path4 = self.assertPathExists(
- ([interface7, interface8], cable5, frontport2_2, rearport2, cable3, rearport1, frontport1_2, cable2, [interface3, interface4]),
+ (
+ [interface7, interface8],
+ cable5,
+ frontport2_2,
+ rearport2,
+ cable3,
+ rearport1,
+ frontport1_2,
+ cable2,
+ [interface3, interface4],
+ ),
is_complete=True,
- is_active=True
+ is_active=True,
)
self.assertEqual(CablePath.objects.count(), 4)
@@ -1167,7 +1207,11 @@ class CablePathTestCase(TestCase):
[IF1] --C1-- [CT1]
"""
interface1 = Interface.objects.create(device=self.device, name='Interface 1')
- circuittermination1 = CircuitTermination.objects.create(circuit=self.circuit, termination=self.site, term_side='A')
+ circuittermination1 = CircuitTermination.objects.create(
+ circuit=self.circuit,
+ termination=self.site,
+ term_side='A'
+ )
# Create cable 1
cable1 = Cable(
@@ -1198,7 +1242,11 @@ class CablePathTestCase(TestCase):
"""
interface1 = Interface.objects.create(device=self.device, name='Interface 1')
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
- circuittermination1 = CircuitTermination.objects.create(circuit=self.circuit, termination=self.site, term_side='A')
+ circuittermination1 = CircuitTermination.objects.create(
+ circuit=self.circuit,
+ termination=self.site,
+ term_side='A'
+ )
# Create cable 1
cable1 = Cable(
@@ -1214,7 +1262,11 @@ class CablePathTestCase(TestCase):
)
# Create CT2
- circuittermination2 = CircuitTermination.objects.create(circuit=self.circuit, termination=self.site, term_side='Z')
+ circuittermination2 = CircuitTermination.objects.create(
+ circuit=self.circuit,
+ termination=self.site,
+ term_side='Z'
+ )
# Check for partial path to site
self.assertPathExists(
@@ -1266,7 +1318,11 @@ class CablePathTestCase(TestCase):
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
interface3 = Interface.objects.create(device=self.device, name='Interface 3')
interface4 = Interface.objects.create(device=self.device, name='Interface 4')
- circuittermination1 = CircuitTermination.objects.create(circuit=self.circuit, termination=self.site, term_side='A')
+ circuittermination1 = CircuitTermination.objects.create(
+ circuit=self.circuit,
+ termination=self.site,
+ term_side='A'
+ )
# Create cable 1
cable1 = Cable(
@@ -1282,7 +1338,11 @@ class CablePathTestCase(TestCase):
)
# Create CT2
- circuittermination2 = CircuitTermination.objects.create(circuit=self.circuit, termination=self.site, term_side='Z')
+ circuittermination2 = CircuitTermination.objects.create(
+ circuit=self.circuit,
+ termination=self.site,
+ term_side='Z'
+ )
# Check for partial path to site
self.assertPathExists(
@@ -1299,14 +1359,28 @@ class CablePathTestCase(TestCase):
# Check for complete path in each direction
self.assertPathExists(
- ([interface1, interface2], cable1, circuittermination1, circuittermination2, cable2, [interface3, interface4]),
+ (
+ [interface1, interface2],
+ cable1,
+ circuittermination1,
+ circuittermination2,
+ cable2,
+ [interface3, interface4],
+ ),
is_complete=True,
- is_active=True
+ is_active=True,
)
self.assertPathExists(
- ([interface3, interface4], cable2, circuittermination2, circuittermination1, cable1, [interface1, interface2]),
+ (
+ [interface3, interface4],
+ cable2,
+ circuittermination2,
+ circuittermination1,
+ cable1,
+ [interface1, interface2],
+ ),
is_complete=True,
- is_active=True
+ is_active=True,
)
self.assertEqual(CablePath.objects.count(), 2)
@@ -1335,8 +1409,16 @@ class CablePathTestCase(TestCase):
"""
interface1 = Interface.objects.create(device=self.device, name='Interface 1')
site2 = Site.objects.create(name='Site 2', slug='site-2')
- circuittermination1 = CircuitTermination.objects.create(circuit=self.circuit, termination=self.site, term_side='A')
- circuittermination2 = CircuitTermination.objects.create(circuit=self.circuit, termination=site2, term_side='Z')
+ circuittermination1 = CircuitTermination.objects.create(
+ circuit=self.circuit,
+ termination=self.site,
+ term_side='A'
+ )
+ circuittermination2 = CircuitTermination.objects.create(
+ circuit=self.circuit,
+ termination=site2,
+ term_side='Z'
+ )
# Create cable 1
cable1 = Cable(
@@ -1365,8 +1447,16 @@ class CablePathTestCase(TestCase):
"""
interface1 = Interface.objects.create(device=self.device, name='Interface 1')
providernetwork = ProviderNetwork.objects.create(name='Provider Network 1', provider=self.circuit.provider)
- circuittermination1 = CircuitTermination.objects.create(circuit=self.circuit, termination=self.site, term_side='A')
- circuittermination2 = CircuitTermination.objects.create(circuit=self.circuit, termination=providernetwork, term_side='Z')
+ circuittermination1 = CircuitTermination.objects.create(
+ circuit=self.circuit,
+ termination=self.site,
+ term_side='A'
+ )
+ circuittermination2 = CircuitTermination.objects.create(
+ circuit=self.circuit,
+ termination=providernetwork,
+ term_side='Z'
+ )
# Create cable 1
cable1 = Cable(
@@ -1413,8 +1503,15 @@ class CablePathTestCase(TestCase):
frontport2_2 = FrontPort.objects.create(
device=self.device, name='Front Port 2:2', rear_port=rearport2, rear_port_position=2
)
- circuittermination1 = CircuitTermination.objects.create(circuit=self.circuit, termination=self.site, term_side='A')
- circuittermination2 = CircuitTermination.objects.create(circuit=self.circuit, termination=self.site, term_side='Z')
+ circuittermination1 = CircuitTermination.objects.create(
+ circuit=self.circuit,
+ termination=self.site,
+ term_side='A'
+ )
+ circuittermination2 = CircuitTermination.objects.create(
+ circuit=self.circuit,
+ termination=self.site, term_side='Z'
+ )
# Create cables
cable1 = Cable(
@@ -1499,10 +1596,26 @@ class CablePathTestCase(TestCase):
interface1 = Interface.objects.create(device=self.device, name='Interface 1')
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
circuit2 = Circuit.objects.create(provider=self.circuit.provider, type=self.circuit.type, cid='Circuit 2')
- circuittermination1 = CircuitTermination.objects.create(circuit=self.circuit, termination=self.site, term_side='A')
- circuittermination2 = CircuitTermination.objects.create(circuit=self.circuit, termination=self.site, term_side='Z')
- circuittermination3 = CircuitTermination.objects.create(circuit=circuit2, termination=self.site, term_side='A')
- circuittermination4 = CircuitTermination.objects.create(circuit=circuit2, termination=self.site, term_side='Z')
+ circuittermination1 = CircuitTermination.objects.create(
+ circuit=self.circuit,
+ termination=self.site,
+ term_side='A'
+ )
+ circuittermination2 = CircuitTermination.objects.create(
+ circuit=self.circuit,
+ termination=self.site,
+ term_side='Z'
+ )
+ circuittermination3 = CircuitTermination.objects.create(
+ circuit=circuit2,
+ termination=self.site,
+ term_side='A'
+ )
+ circuittermination4 = CircuitTermination.objects.create(
+ circuit=circuit2,
+ termination=self.site,
+ term_side='Z'
+ )
# Create cables
cable1 = Cable(
@@ -1706,45 +1819,95 @@ class CablePathTestCase(TestCase):
)
cable3.save()
self.assertPathExists(
- (interface1, cable1, (frontport1_1, frontport1_2), rearport1, cable3, rearport2, (frontport2_1, frontport2_2)),
- is_complete=False
+ (
+ interface1,
+ cable1,
+ (frontport1_1, frontport1_2),
+ rearport1,
+ cable3,
+ rearport2,
+ (frontport2_1, frontport2_2),
+ ),
+ is_complete=False,
)
self.assertPathExists(
- (interface2, cable2, (frontport1_3, frontport1_4), rearport1, cable3, rearport2, (frontport2_3, frontport2_4)),
- is_complete=False
+ (
+ interface2,
+ cable2,
+ (frontport1_3, frontport1_4),
+ rearport1,
+ cable3,
+ rearport2,
+ (frontport2_3, frontport2_4),
+ ),
+ is_complete=False,
)
self.assertEqual(CablePath.objects.count(), 2)
# Create cables 4-5
- cable4 = Cable(
- a_terminations=[frontport2_1, frontport2_2],
- b_terminations=[interface3]
- )
+ cable4 = Cable(a_terminations=[frontport2_1, frontport2_2], b_terminations=[interface3])
cable4.save()
- cable5 = Cable(
- a_terminations=[frontport2_3, frontport2_4],
- b_terminations=[interface4]
- )
+ cable5 = Cable(a_terminations=[frontport2_3, frontport2_4], b_terminations=[interface4])
cable5.save()
path1 = self.assertPathExists(
- (interface1, cable1, (frontport1_1, frontport1_2), rearport1, cable3, rearport2, (frontport2_1, frontport2_2), cable4, interface3),
+ (
+ interface1,
+ cable1,
+ (frontport1_1, frontport1_2),
+ rearport1,
+ cable3,
+ rearport2,
+ (frontport2_1, frontport2_2),
+ cable4,
+ interface3,
+ ),
is_complete=True,
- is_active=True
+ is_active=True,
)
path2 = self.assertPathExists(
- (interface2, cable2, (frontport1_3, frontport1_4), rearport1, cable3, rearport2, (frontport2_3, frontport2_4), cable5, interface4),
+ (
+ interface2,
+ cable2,
+ (frontport1_3, frontport1_4),
+ rearport1,
+ cable3,
+ rearport2,
+ (frontport2_3, frontport2_4),
+ cable5,
+ interface4,
+ ),
is_complete=True,
- is_active=True
+ is_active=True,
)
path3 = self.assertPathExists(
- (interface3, cable4, (frontport2_1, frontport2_2), rearport2, cable3, rearport1, (frontport1_1, frontport1_2), cable1, interface1),
+ (
+ interface3,
+ cable4,
+ (frontport2_1, frontport2_2),
+ rearport2,
+ cable3,
+ rearport1,
+ (frontport1_1, frontport1_2),
+ cable1,
+ interface1,
+ ),
is_complete=True,
- is_active=True
+ is_active=True,
)
path4 = self.assertPathExists(
- (interface4, cable5, (frontport2_3, frontport2_4), rearport2, cable3, rearport1, (frontport1_3, frontport1_4), cable2, interface2),
+ (
+ interface4,
+ cable5,
+ (frontport2_3, frontport2_4),
+ rearport2,
+ cable3,
+ rearport1,
+ (frontport1_3, frontport1_4),
+ cable2,
+ interface2,
+ ),
is_complete=True,
- is_active=True
+ is_active=True,
)
self.assertEqual(CablePath.objects.count(), 4)
@@ -1809,7 +1972,10 @@ class CablePathTestCase(TestCase):
)
cable1.save()
self.assertPathExists(
- (interface1, cable1, (frontport1, frontport3), (rearport1, rearport3), (cable2, cable4), (rearport2, rearport4), (frontport2, frontport4)),
+ (
+ interface1, cable1, (frontport1, frontport3), (rearport1, rearport3), (cable2, cable4),
+ (rearport2, rearport4), (frontport2, frontport4)
+ ),
is_complete=False
)
self.assertEqual(CablePath.objects.count(), 1)
diff --git a/netbox/dcim/tests/test_filtersets.py b/netbox/dcim/tests/test_filtersets.py
index 897612b84..ede1e2a09 100644
--- a/netbox/dcim/tests/test_filtersets.py
+++ b/netbox/dcim/tests/test_filtersets.py
@@ -243,9 +243,41 @@ class SiteTestCase(TestCase, ChangeLoggedFilterSetTests):
ASN.objects.bulk_create(asns)
sites = (
- Site(name='Site 1', slug='site-1', region=regions[0], group=groups[0], tenant=tenants[0], status=SiteStatusChoices.STATUS_ACTIVE, facility='Facility 1', latitude=10, longitude=10, description='foobar1'),
- Site(name='Site 2', slug='site-2', region=regions[1], group=groups[1], tenant=tenants[1], status=SiteStatusChoices.STATUS_PLANNED, facility='Facility 2', latitude=20, longitude=20, description='foobar2'),
- Site(name='Site 3', slug='site-3', region=regions[2], group=groups[2], tenant=tenants[2], status=SiteStatusChoices.STATUS_RETIRED, facility='Facility 3', latitude=30, longitude=30),
+ Site(
+ name='Site 1',
+ slug='site-1',
+ region=regions[0],
+ group=groups[0],
+ tenant=tenants[0],
+ status=SiteStatusChoices.STATUS_ACTIVE,
+ facility='Facility 1',
+ latitude=10,
+ longitude=10,
+ description='foobar1',
+ ),
+ Site(
+ name='Site 2',
+ slug='site-2',
+ region=regions[1],
+ group=groups[1],
+ tenant=tenants[1],
+ status=SiteStatusChoices.STATUS_PLANNED,
+ facility='Facility 2',
+ latitude=20,
+ longitude=20,
+ description='foobar2',
+ ),
+ Site(
+ name='Site 3',
+ slug='site-3',
+ region=regions[2],
+ group=groups[2],
+ tenant=tenants[2],
+ status=SiteStatusChoices.STATUS_RETIRED,
+ facility='Facility 3',
+ latitude=30,
+ longitude=30,
+ ),
)
Site.objects.bulk_create(sites)
sites[0].asns.set([asns[0]])
@@ -361,9 +393,33 @@ class LocationTestCase(TestCase, ChangeLoggedFilterSetTests):
location.save()
locations = (
- Location(name='Location 1A', slug='location-1a', site=sites[0], parent=parent_locations[0], status=LocationStatusChoices.STATUS_PLANNED, facility='Facility 1', description='foobar1'),
- Location(name='Location 2A', slug='location-2a', site=sites[1], parent=parent_locations[1], status=LocationStatusChoices.STATUS_STAGING, facility='Facility 2', description='foobar2'),
- Location(name='Location 3A', slug='location-3a', site=sites[2], parent=parent_locations[2], status=LocationStatusChoices.STATUS_DECOMMISSIONING, facility='Facility 3', description='foobar3'),
+ Location(
+ name='Location 1A',
+ slug='location-1a',
+ site=sites[0],
+ parent=parent_locations[0],
+ status=LocationStatusChoices.STATUS_PLANNED,
+ facility='Facility 1',
+ description='foobar1',
+ ),
+ Location(
+ name='Location 2A',
+ slug='location-2a',
+ site=sites[1],
+ parent=parent_locations[1],
+ status=LocationStatusChoices.STATUS_STAGING,
+ facility='Facility 2',
+ description='foobar2',
+ ),
+ Location(
+ name='Location 3A',
+ slug='location-3a',
+ site=sites[2],
+ parent=parent_locations[2],
+ status=LocationStatusChoices.STATUS_DECOMMISSIONING,
+ facility='Facility 3',
+ description='foobar3',
+ ),
)
for location in locations:
location.save()
@@ -1222,10 +1278,22 @@ class DeviceTypeTestCase(TestCase, ChangeLoggedFilterSetTests):
RearPortTemplate(device_type=device_types[1], name='Rear Port 2', type=PortTypeChoices.TYPE_8P8C),
)
RearPortTemplate.objects.bulk_create(rear_ports)
- FrontPortTemplate.objects.bulk_create((
- FrontPortTemplate(device_type=device_types[0], name='Front Port 1', type=PortTypeChoices.TYPE_8P8C, rear_port=rear_ports[0]),
- FrontPortTemplate(device_type=device_types[1], name='Front Port 2', type=PortTypeChoices.TYPE_8P8C, rear_port=rear_ports[1]),
- ))
+ FrontPortTemplate.objects.bulk_create(
+ (
+ FrontPortTemplate(
+ device_type=device_types[0],
+ name='Front Port 1',
+ type=PortTypeChoices.TYPE_8P8C,
+ rear_port=rear_ports[0],
+ ),
+ FrontPortTemplate(
+ device_type=device_types[1],
+ name='Front Port 2',
+ type=PortTypeChoices.TYPE_8P8C,
+ rear_port=rear_ports[1],
+ ),
+ )
+ )
ModuleBayTemplate.objects.bulk_create((
ModuleBayTemplate(device_type=device_types[0], name='Module Bay 1'),
ModuleBayTemplate(device_type=device_types[1], name='Module Bay 2'),
@@ -1435,10 +1503,22 @@ class ModuleTypeTestCase(TestCase, ChangeLoggedFilterSetTests):
RearPortTemplate(module_type=module_types[1], name='Rear Port 2', type=PortTypeChoices.TYPE_8P8C),
)
RearPortTemplate.objects.bulk_create(rear_ports)
- FrontPortTemplate.objects.bulk_create((
- FrontPortTemplate(module_type=module_types[0], name='Front Port 1', type=PortTypeChoices.TYPE_8P8C, rear_port=rear_ports[0]),
- FrontPortTemplate(module_type=module_types[1], name='Front Port 2', type=PortTypeChoices.TYPE_8P8C, rear_port=rear_ports[1]),
- ))
+ FrontPortTemplate.objects.bulk_create(
+ (
+ FrontPortTemplate(
+ module_type=module_types[0],
+ name='Front Port 1',
+ type=PortTypeChoices.TYPE_8P8C,
+ rear_port=rear_ports[0],
+ ),
+ FrontPortTemplate(
+ module_type=module_types[1],
+ name='Front Port 2',
+ type=PortTypeChoices.TYPE_8P8C,
+ rear_port=rear_ports[1],
+ ),
+ )
+ )
def test_q(self):
params = {'q': 'foobar1'}
@@ -1893,11 +1973,19 @@ class ModuleBayTemplateTestCase(TestCase, DeviceComponentTemplateFilterSetTests,
)
ModuleType.objects.bulk_create(module_types)
- ModuleBayTemplate.objects.bulk_create((
- ModuleBayTemplate(device_type=device_types[0], name='Module Bay 1', description='foobar1'),
- ModuleBayTemplate(device_type=device_types[1], name='Module Bay 2', description='foobar2', module_type=module_types[0]),
- ModuleBayTemplate(device_type=device_types[2], name='Module Bay 3', description='foobar3', module_type=module_types[1]),
- ))
+ ModuleBayTemplate.objects.bulk_create(
+ (
+ ModuleBayTemplate(
+ device_type=device_types[0], name='Module Bay 1', description='foobar1'
+ ),
+ ModuleBayTemplate(
+ device_type=device_types[1], name='Module Bay 2', description='foobar2', module_type=module_types[0]
+ ),
+ ModuleBayTemplate(
+ device_type=device_types[2], name='Module Bay 3', description='foobar3', module_type=module_types[1]
+ ),
+ )
+ )
def test_name(self):
params = {'name': ['Module Bay 1', 'Module Bay 2']}
@@ -1996,9 +2084,15 @@ class InventoryItemTemplateTestCase(TestCase, DeviceComponentTemplateFilterSetTe
item.save()
child_inventory_item_templates = (
- InventoryItemTemplate(device_type=device_types[0], name='Inventory Item 1A', parent=inventory_item_templates[0]),
- InventoryItemTemplate(device_type=device_types[1], name='Inventory Item 2A', parent=inventory_item_templates[1]),
- InventoryItemTemplate(device_type=device_types[2], name='Inventory Item 3A', parent=inventory_item_templates[2]),
+ InventoryItemTemplate(
+ device_type=device_types[0], name='Inventory Item 1A', parent=inventory_item_templates[0]
+ ),
+ InventoryItemTemplate(
+ device_type=device_types[1], name='Inventory Item 2A', parent=inventory_item_templates[1]
+ ),
+ InventoryItemTemplate(
+ device_type=device_types[2], name='Inventory Item 3A', parent=inventory_item_templates[2]
+ ),
)
for item in child_inventory_item_templates:
item.save()
@@ -2848,10 +2942,41 @@ class ConsolePortTestCase(TestCase, DeviceComponentFilterSetTests, ChangeLoggedF
Rack.objects.bulk_create(racks)
devices = (
- Device(name='Device 1', device_type=device_types[0], role=roles[0], site=sites[0], location=locations[0], rack=racks[0], status='active'),
- Device(name='Device 2', device_type=device_types[1], role=roles[1], site=sites[1], location=locations[1], rack=racks[1], status='planned'),
- Device(name='Device 3', device_type=device_types[2], role=roles[2], site=sites[2], location=locations[2], rack=racks[2], status='offline'),
- Device(name=None, device_type=device_types[0], role=roles[0], site=sites[3], status='offline'), # For cable connections
+ Device(
+ name='Device 1',
+ device_type=device_types[0],
+ role=roles[0],
+ site=sites[0],
+ location=locations[0],
+ rack=racks[0],
+ status='active',
+ ),
+ Device(
+ name='Device 2',
+ device_type=device_types[1],
+ role=roles[1],
+ site=sites[1],
+ location=locations[1],
+ rack=racks[1],
+ status='planned',
+ ),
+ Device(
+ name='Device 3',
+ device_type=device_types[2],
+ role=roles[2],
+ site=sites[2],
+ location=locations[2],
+ rack=racks[2],
+ status='offline',
+ ),
+ # For cable connections
+ Device(
+ name=None,
+ device_type=device_types[0],
+ role=roles[0],
+ site=sites[3],
+ status='offline'
+ ),
)
Device.objects.bulk_create(devices)
@@ -3029,10 +3154,41 @@ class ConsoleServerPortTestCase(TestCase, DeviceComponentFilterSetTests, ChangeL
Rack.objects.bulk_create(racks)
devices = (
- Device(name='Device 1', device_type=device_types[0], role=roles[0], site=sites[0], location=locations[0], rack=racks[0], status='active'),
- Device(name='Device 2', device_type=device_types[1], role=roles[1], site=sites[1], location=locations[1], rack=racks[1], status='planned'),
- Device(name='Device 3', device_type=device_types[2], role=roles[2], site=sites[2], location=locations[2], rack=racks[2], status='offline'),
- Device(name=None, device_type=device_types[2], role=roles[2], site=sites[3], status='offline'), # For cable connections
+ Device(
+ name='Device 1',
+ device_type=device_types[0],
+ role=roles[0],
+ site=sites[0],
+ location=locations[0],
+ rack=racks[0],
+ status='active',
+ ),
+ Device(
+ name='Device 2',
+ device_type=device_types[1],
+ role=roles[1],
+ site=sites[1],
+ location=locations[1],
+ rack=racks[1],
+ status='planned',
+ ),
+ Device(
+ name='Device 3',
+ device_type=device_types[2],
+ role=roles[2],
+ site=sites[2],
+ location=locations[2],
+ rack=racks[2],
+ status='offline',
+ ),
+ # For cable connections
+ Device(
+ name=None,
+ device_type=device_types[2],
+ role=roles[2],
+ site=sites[3],
+ status='offline'
+ ),
)
Device.objects.bulk_create(devices)
@@ -3058,9 +3214,15 @@ class ConsoleServerPortTestCase(TestCase, DeviceComponentFilterSetTests, ChangeL
ConsolePort.objects.bulk_create(console_ports)
console_server_ports = (
- ConsoleServerPort(device=devices[0], module=modules[0], name='Console Server Port 1', label='A', description='First'),
- ConsoleServerPort(device=devices[1], module=modules[1], name='Console Server Port 2', label='B', description='Second'),
- ConsoleServerPort(device=devices[2], module=modules[2], name='Console Server Port 3', label='C', description='Third'),
+ ConsoleServerPort(
+ device=devices[0], module=modules[0], name='Console Server Port 1', label='A', description='First'
+ ),
+ ConsoleServerPort(
+ device=devices[1], module=modules[1], name='Console Server Port 2', label='B', description='Second'
+ ),
+ ConsoleServerPort(
+ device=devices[2], module=modules[2], name='Console Server Port 3', label='C', description='Third'
+ ),
)
ConsoleServerPort.objects.bulk_create(console_server_ports)
@@ -3210,10 +3372,41 @@ class PowerPortTestCase(TestCase, DeviceComponentFilterSetTests, ChangeLoggedFil
Rack.objects.bulk_create(racks)
devices = (
- Device(name='Device 1', device_type=device_types[0], role=roles[0], site=sites[0], location=locations[0], rack=racks[0], status='active'),
- Device(name='Device 2', device_type=device_types[1], role=roles[1], site=sites[1], location=locations[1], rack=racks[1], status='planned'),
- Device(name='Device 3', device_type=device_types[2], role=roles[2], site=sites[2], location=locations[2], rack=racks[2], status='offline'),
- Device(name=None, device_type=device_types[2], role=roles[2], site=sites[3], status='offline'), # For cable connections
+ Device(
+ name='Device 1',
+ device_type=device_types[0],
+ role=roles[0],
+ site=sites[0],
+ location=locations[0],
+ rack=racks[0],
+ status='active',
+ ),
+ Device(
+ name='Device 2',
+ device_type=device_types[1],
+ role=roles[1],
+ site=sites[1],
+ location=locations[1],
+ rack=racks[1],
+ status='planned',
+ ),
+ Device(
+ name='Device 3',
+ device_type=device_types[2],
+ role=roles[2],
+ site=sites[2],
+ location=locations[2],
+ rack=racks[2],
+ status='offline',
+ ),
+ # For cable connections
+ Device(
+ name=None,
+ device_type=device_types[2],
+ role=roles[2],
+ site=sites[3],
+ status='offline'
+ ),
)
Device.objects.bulk_create(devices)
@@ -3239,9 +3432,33 @@ class PowerPortTestCase(TestCase, DeviceComponentFilterSetTests, ChangeLoggedFil
PowerOutlet.objects.bulk_create(power_outlets)
power_ports = (
- PowerPort(device=devices[0], module=modules[0], name='Power Port 1', label='A', maximum_draw=100, allocated_draw=50, description='First'),
- PowerPort(device=devices[1], module=modules[1], name='Power Port 2', label='B', maximum_draw=200, allocated_draw=100, description='Second'),
- PowerPort(device=devices[2], module=modules[2], name='Power Port 3', label='C', maximum_draw=300, allocated_draw=150, description='Third'),
+ PowerPort(
+ device=devices[0],
+ module=modules[0],
+ name='Power Port 1',
+ label='A',
+ maximum_draw=100,
+ allocated_draw=50,
+ description='First',
+ ),
+ PowerPort(
+ device=devices[1],
+ module=modules[1],
+ name='Power Port 2',
+ label='B',
+ maximum_draw=200,
+ allocated_draw=100,
+ description='Second',
+ ),
+ PowerPort(
+ device=devices[2],
+ module=modules[2],
+ name='Power Port 3',
+ label='C',
+ maximum_draw=300,
+ allocated_draw=150,
+ description='Third',
+ ),
)
PowerPort.objects.bulk_create(power_ports)
@@ -3399,10 +3616,41 @@ class PowerOutletTestCase(TestCase, DeviceComponentFilterSetTests, ChangeLoggedF
Rack.objects.bulk_create(racks)
devices = (
- Device(name='Device 1', device_type=device_types[0], role=roles[0], site=sites[0], location=locations[0], rack=racks[0], status='active'),
- Device(name='Device 2', device_type=device_types[1], role=roles[1], site=sites[1], location=locations[1], rack=racks[1], status='planned'),
- Device(name='Device 3', device_type=device_types[2], role=roles[2], site=sites[2], location=locations[2], rack=racks[2], status='offline'),
- Device(name=None, device_type=device_types[2], role=roles[2], site=sites[3], status='offline'), # For cable connections
+ Device(
+ name='Device 1',
+ device_type=device_types[0],
+ role=roles[0],
+ site=sites[0],
+ location=locations[0],
+ rack=racks[0],
+ status='active',
+ ),
+ Device(
+ name='Device 2',
+ device_type=device_types[1],
+ role=roles[1],
+ site=sites[1],
+ location=locations[1],
+ rack=racks[1],
+ status='planned',
+ ),
+ Device(
+ name='Device 3',
+ device_type=device_types[2],
+ role=roles[2],
+ site=sites[2],
+ location=locations[2],
+ rack=racks[2],
+ status='offline',
+ ),
+ # For cable connections
+ Device(
+ name=None,
+ device_type=device_types[2],
+ role=roles[2],
+ site=sites[3],
+ status='offline'
+ ),
)
Device.objects.bulk_create(devices)
@@ -3428,9 +3676,33 @@ class PowerOutletTestCase(TestCase, DeviceComponentFilterSetTests, ChangeLoggedF
PowerPort.objects.bulk_create(power_ports)
power_outlets = (
- PowerOutlet(device=devices[0], module=modules[0], name='Power Outlet 1', label='A', feed_leg=PowerOutletFeedLegChoices.FEED_LEG_A, description='First', color='ff0000'),
- PowerOutlet(device=devices[1], module=modules[1], name='Power Outlet 2', label='B', feed_leg=PowerOutletFeedLegChoices.FEED_LEG_B, description='Second', color='00ff00'),
- PowerOutlet(device=devices[2], module=modules[2], name='Power Outlet 3', label='C', feed_leg=PowerOutletFeedLegChoices.FEED_LEG_C, description='Third', color='0000ff'),
+ PowerOutlet(
+ device=devices[0],
+ module=modules[0],
+ name='Power Outlet 1',
+ label='A',
+ feed_leg=PowerOutletFeedLegChoices.FEED_LEG_A,
+ description='First',
+ color='ff0000',
+ ),
+ PowerOutlet(
+ device=devices[1],
+ module=modules[1],
+ name='Power Outlet 2',
+ label='B',
+ feed_leg=PowerOutletFeedLegChoices.FEED_LEG_B,
+ description='Second',
+ color='00ff00',
+ ),
+ PowerOutlet(
+ device=devices[2],
+ module=modules[2],
+ name='Power Outlet 3',
+ label='C',
+ feed_leg=PowerOutletFeedLegChoices.FEED_LEG_C,
+ description='Third',
+ color='0000ff',
+ ),
)
PowerOutlet.objects.bulk_create(power_outlets)
@@ -3672,8 +3944,12 @@ class InterfaceTestCase(TestCase, DeviceComponentFilterSetTests, ChangeLoggedFil
# Virtual Device Context Creation
vdcs = (
- VirtualDeviceContext(device=devices[4], name='VDC 1', identifier=1, status=VirtualDeviceContextStatusChoices.STATUS_ACTIVE),
- VirtualDeviceContext(device=devices[4], name='VDC 2', identifier=2, status=VirtualDeviceContextStatusChoices.STATUS_PLANNED),
+ VirtualDeviceContext(
+ device=devices[4], name='VDC 1', identifier=1, status=VirtualDeviceContextStatusChoices.STATUS_ACTIVE
+ ),
+ VirtualDeviceContext(
+ device=devices[4], name='VDC 2', identifier=2, status=VirtualDeviceContextStatusChoices.STATUS_PLANNED
+ ),
)
VirtualDeviceContext.objects.bulk_create(vdcs)
@@ -3886,9 +4162,24 @@ class InterfaceTestCase(TestCase, DeviceComponentFilterSetTests, ChangeLoggedFil
# Create child interfaces
parent_interface = Interface.objects.first()
child_interfaces = (
- Interface(device=parent_interface.device, name='Child 1', parent=parent_interface, type=InterfaceTypeChoices.TYPE_VIRTUAL),
- Interface(device=parent_interface.device, name='Child 2', parent=parent_interface, type=InterfaceTypeChoices.TYPE_VIRTUAL),
- Interface(device=parent_interface.device, name='Child 3', parent=parent_interface, type=InterfaceTypeChoices.TYPE_VIRTUAL),
+ Interface(
+ device=parent_interface.device,
+ name='Child 1',
+ parent=parent_interface,
+ type=InterfaceTypeChoices.TYPE_VIRTUAL,
+ ),
+ Interface(
+ device=parent_interface.device,
+ name='Child 2',
+ parent=parent_interface,
+ type=InterfaceTypeChoices.TYPE_VIRTUAL,
+ ),
+ Interface(
+ device=parent_interface.device,
+ name='Child 3',
+ parent=parent_interface,
+ type=InterfaceTypeChoices.TYPE_VIRTUAL,
+ ),
)
Interface.objects.bulk_create(child_interfaces)
@@ -3899,9 +4190,24 @@ class InterfaceTestCase(TestCase, DeviceComponentFilterSetTests, ChangeLoggedFil
# Create bridged interfaces
bridge_interface = Interface.objects.first()
bridged_interfaces = (
- Interface(device=bridge_interface.device, name='Bridged 1', bridge=bridge_interface, type=InterfaceTypeChoices.TYPE_1GE_FIXED),
- Interface(device=bridge_interface.device, name='Bridged 2', bridge=bridge_interface, type=InterfaceTypeChoices.TYPE_1GE_FIXED),
- Interface(device=bridge_interface.device, name='Bridged 3', bridge=bridge_interface, type=InterfaceTypeChoices.TYPE_1GE_FIXED),
+ Interface(
+ device=bridge_interface.device,
+ name='Bridged 1',
+ bridge=bridge_interface,
+ type=InterfaceTypeChoices.TYPE_1GE_FIXED,
+ ),
+ Interface(
+ device=bridge_interface.device,
+ name='Bridged 2',
+ bridge=bridge_interface,
+ type=InterfaceTypeChoices.TYPE_1GE_FIXED,
+ ),
+ Interface(
+ device=bridge_interface.device,
+ name='Bridged 3',
+ bridge=bridge_interface,
+ type=InterfaceTypeChoices.TYPE_1GE_FIXED,
+ ),
)
Interface.objects.bulk_create(bridged_interfaces)
@@ -4134,10 +4440,41 @@ class FrontPortTestCase(TestCase, DeviceComponentFilterSetTests, ChangeLoggedFil
Rack.objects.bulk_create(racks)
devices = (
- Device(name='Device 1', device_type=device_types[0], role=roles[0], site=sites[0], location=locations[0], rack=racks[0], status='active'),
- Device(name='Device 2', device_type=device_types[1], role=roles[1], site=sites[1], location=locations[1], rack=racks[1], status='planned'),
- Device(name='Device 3', device_type=device_types[2], role=roles[2], site=sites[2], location=locations[2], rack=racks[2], status='offline'),
- Device(name=None, device_type=device_types[2], role=roles[2], site=sites[3], status='offline'), # For cable connections
+ Device(
+ name='Device 1',
+ device_type=device_types[0],
+ role=roles[0],
+ site=sites[0],
+ location=locations[0],
+ rack=racks[0],
+ status='active',
+ ),
+ Device(
+ name='Device 2',
+ device_type=device_types[1],
+ role=roles[1],
+ site=sites[1],
+ location=locations[1],
+ rack=racks[1],
+ status='planned',
+ ),
+ Device(
+ name='Device 3',
+ device_type=device_types[2],
+ role=roles[2],
+ site=sites[2],
+ location=locations[2],
+ rack=racks[2],
+ status='offline',
+ ),
+ # For cable connections
+ Device(
+ name=None,
+ device_type=device_types[2],
+ role=roles[2],
+ site=sites[3],
+ status='offline'
+ ),
)
Device.objects.bulk_create(devices)
@@ -4167,12 +4504,63 @@ class FrontPortTestCase(TestCase, DeviceComponentFilterSetTests, ChangeLoggedFil
RearPort.objects.bulk_create(rear_ports)
front_ports = (
- FrontPort(device=devices[0], module=modules[0], name='Front Port 1', label='A', type=PortTypeChoices.TYPE_8P8C, color=ColorChoices.COLOR_RED, rear_port=rear_ports[0], rear_port_position=1, description='First'),
- FrontPort(device=devices[1], module=modules[1], name='Front Port 2', label='B', type=PortTypeChoices.TYPE_110_PUNCH, color=ColorChoices.COLOR_GREEN, rear_port=rear_ports[1], rear_port_position=2, description='Second'),
- FrontPort(device=devices[2], module=modules[2], name='Front Port 3', label='C', type=PortTypeChoices.TYPE_BNC, color=ColorChoices.COLOR_BLUE, rear_port=rear_ports[2], rear_port_position=3, description='Third'),
- FrontPort(device=devices[3], name='Front Port 4', label='D', type=PortTypeChoices.TYPE_FC, rear_port=rear_ports[3], rear_port_position=1),
- FrontPort(device=devices[3], name='Front Port 5', label='E', type=PortTypeChoices.TYPE_FC, rear_port=rear_ports[4], rear_port_position=1),
- FrontPort(device=devices[3], name='Front Port 6', label='F', type=PortTypeChoices.TYPE_FC, rear_port=rear_ports[5], rear_port_position=1),
+ FrontPort(
+ device=devices[0],
+ module=modules[0],
+ name='Front Port 1',
+ label='A',
+ type=PortTypeChoices.TYPE_8P8C,
+ color=ColorChoices.COLOR_RED,
+ rear_port=rear_ports[0],
+ rear_port_position=1,
+ description='First',
+ ),
+ FrontPort(
+ device=devices[1],
+ module=modules[1],
+ name='Front Port 2',
+ label='B',
+ type=PortTypeChoices.TYPE_110_PUNCH,
+ color=ColorChoices.COLOR_GREEN,
+ rear_port=rear_ports[1],
+ rear_port_position=2,
+ description='Second',
+ ),
+ FrontPort(
+ device=devices[2],
+ module=modules[2],
+ name='Front Port 3',
+ label='C',
+ type=PortTypeChoices.TYPE_BNC,
+ color=ColorChoices.COLOR_BLUE,
+ rear_port=rear_ports[2],
+ rear_port_position=3,
+ description='Third',
+ ),
+ FrontPort(
+ device=devices[3],
+ name='Front Port 4',
+ label='D',
+ type=PortTypeChoices.TYPE_FC,
+ rear_port=rear_ports[3],
+ rear_port_position=1,
+ ),
+ FrontPort(
+ device=devices[3],
+ name='Front Port 5',
+ label='E',
+ type=PortTypeChoices.TYPE_FC,
+ rear_port=rear_ports[4],
+ rear_port_position=1,
+ ),
+ FrontPort(
+ device=devices[3],
+ name='Front Port 6',
+ label='F',
+ type=PortTypeChoices.TYPE_FC,
+ rear_port=rear_ports[5],
+ rear_port_position=1,
+ ),
)
FrontPort.objects.bulk_create(front_ports)
@@ -4324,10 +4712,41 @@ class RearPortTestCase(TestCase, DeviceComponentFilterSetTests, ChangeLoggedFilt
Rack.objects.bulk_create(racks)
devices = (
- Device(name='Device 1', device_type=device_types[0], role=roles[0], site=sites[0], location=locations[0], rack=racks[0], status='active'),
- Device(name='Device 2', device_type=device_types[1], role=roles[1], site=sites[1], location=locations[1], rack=racks[1], status='planned'),
- Device(name='Device 3', device_type=device_types[2], role=roles[2], site=sites[2], location=locations[2], rack=racks[2], status='offline'),
- Device(name=None, device_type=device_types[2], role=roles[2], site=sites[3], status='offline'), # For cable connections
+ Device(
+ name='Device 1',
+ device_type=device_types[0],
+ role=roles[0],
+ site=sites[0],
+ location=locations[0],
+ rack=racks[0],
+ status='active',
+ ),
+ Device(
+ name='Device 2',
+ device_type=device_types[1],
+ role=roles[1],
+ site=sites[1],
+ location=locations[1],
+ rack=racks[1],
+ status='planned',
+ ),
+ Device(
+ name='Device 3',
+ device_type=device_types[2],
+ role=roles[2],
+ site=sites[2],
+ location=locations[2],
+ rack=racks[2],
+ status='offline',
+ ),
+ # For cable connections
+ Device(
+ name=None,
+ device_type=device_types[2],
+ role=roles[2],
+ site=sites[3],
+ status='offline'
+ ),
)
Device.objects.bulk_create(devices)
@@ -4347,9 +4766,36 @@ class RearPortTestCase(TestCase, DeviceComponentFilterSetTests, ChangeLoggedFilt
Module.objects.bulk_create(modules)
rear_ports = (
- RearPort(device=devices[0], module=modules[0], name='Rear Port 1', label='A', type=PortTypeChoices.TYPE_8P8C, color=ColorChoices.COLOR_RED, positions=1, description='First'),
- RearPort(device=devices[1], module=modules[1], name='Rear Port 2', label='B', type=PortTypeChoices.TYPE_110_PUNCH, color=ColorChoices.COLOR_GREEN, positions=2, description='Second'),
- RearPort(device=devices[2], module=modules[2], name='Rear Port 3', label='C', type=PortTypeChoices.TYPE_BNC, color=ColorChoices.COLOR_BLUE, positions=3, description='Third'),
+ RearPort(
+ device=devices[0],
+ module=modules[0],
+ name='Rear Port 1',
+ label='A',
+ type=PortTypeChoices.TYPE_8P8C,
+ color=ColorChoices.COLOR_RED,
+ positions=1,
+ description='First',
+ ),
+ RearPort(
+ device=devices[1],
+ module=modules[1],
+ name='Rear Port 2',
+ label='B',
+ type=PortTypeChoices.TYPE_110_PUNCH,
+ color=ColorChoices.COLOR_GREEN,
+ positions=2,
+ description='Second',
+ ),
+ RearPort(
+ device=devices[2],
+ module=modules[2],
+ name='Rear Port 3',
+ label='C',
+ type=PortTypeChoices.TYPE_BNC,
+ color=ColorChoices.COLOR_BLUE,
+ positions=3,
+ description='Third',
+ ),
RearPort(device=devices[3], name='Rear Port 4', label='D', type=PortTypeChoices.TYPE_FC, positions=4),
RearPort(device=devices[3], name='Rear Port 5', label='E', type=PortTypeChoices.TYPE_FC, positions=5),
RearPort(device=devices[3], name='Rear Port 6', label='F', type=PortTypeChoices.TYPE_FC, positions=6),
@@ -4506,9 +4952,33 @@ class ModuleBayTestCase(TestCase, DeviceComponentFilterSetTests, ChangeLoggedFil
Rack.objects.bulk_create(racks)
devices = (
- Device(name='Device 1', device_type=device_types[0], role=roles[0], site=sites[0], location=locations[0], rack=racks[0], status='active'),
- Device(name='Device 2', device_type=device_types[1], role=roles[1], site=sites[1], location=locations[1], rack=racks[1], status='planned'),
- Device(name='Device 3', device_type=device_types[2], role=roles[2], site=sites[2], location=locations[2], rack=racks[2], status='offline'),
+ Device(
+ name='Device 1',
+ device_type=device_types[0],
+ role=roles[0],
+ site=sites[0],
+ location=locations[0],
+ rack=racks[0],
+ status='active',
+ ),
+ Device(
+ name='Device 2',
+ device_type=device_types[1],
+ role=roles[1],
+ site=sites[1],
+ location=locations[1],
+ rack=racks[1],
+ status='planned',
+ ),
+ Device(
+ name='Device 3',
+ device_type=device_types[2],
+ role=roles[2],
+ site=sites[2],
+ location=locations[2],
+ rack=racks[2],
+ status='offline',
+ ),
)
Device.objects.bulk_create(devices)
@@ -4654,9 +5124,33 @@ class DeviceBayTestCase(TestCase, DeviceComponentFilterSetTests, ChangeLoggedFil
Rack.objects.bulk_create(racks)
devices = (
- Device(name='Device 1', device_type=device_types[0], role=roles[0], site=sites[0], location=locations[0], rack=racks[0], status='active'),
- Device(name='Device 2', device_type=device_types[1], role=roles[1], site=sites[1], location=locations[1], rack=racks[1], status='planned'),
- Device(name='Device 3', device_type=device_types[2], role=roles[2], site=sites[2], location=locations[2], rack=racks[2], status='offline'),
+ Device(
+ name='Device 1',
+ device_type=device_types[0],
+ role=roles[0],
+ site=sites[0],
+ location=locations[0],
+ rack=racks[0],
+ status='active',
+ ),
+ Device(
+ name='Device 2',
+ device_type=device_types[1],
+ role=roles[1],
+ site=sites[1],
+ location=locations[1],
+ rack=racks[1],
+ status='planned',
+ ),
+ Device(
+ name='Device 3',
+ device_type=device_types[2],
+ role=roles[2],
+ site=sites[2],
+ location=locations[2],
+ rack=racks[2],
+ status='offline',
+ ),
)
Device.objects.bulk_create(devices)
@@ -4788,9 +5282,30 @@ class InventoryItemTestCase(TestCase, ChangeLoggedFilterSetTests):
Rack.objects.bulk_create(racks)
devices = (
- Device(name='Device 1', device_type=device_types[0], role=roles[0], site=sites[0], location=locations[0], rack=racks[0]),
- Device(name='Device 2', device_type=device_types[1], role=roles[1], site=sites[1], location=locations[1], rack=racks[1]),
- Device(name='Device 3', device_type=device_types[2], role=roles[2], site=sites[2], location=locations[2], rack=racks[2]),
+ Device(
+ name='Device 1',
+ device_type=device_types[0],
+ role=roles[0],
+ site=sites[0],
+ location=locations[0],
+ rack=racks[0],
+ ),
+ Device(
+ name='Device 2',
+ device_type=device_types[1],
+ role=roles[1],
+ site=sites[1],
+ location=locations[1],
+ rack=racks[1],
+ ),
+ Device(
+ name='Device 3',
+ device_type=device_types[2],
+ role=roles[2],
+ site=sites[2],
+ location=locations[2],
+ rack=racks[2],
+ ),
)
Device.objects.bulk_create(devices)
@@ -4808,9 +5323,48 @@ class InventoryItemTestCase(TestCase, ChangeLoggedFilterSetTests):
)
inventory_items = (
- InventoryItem(device=devices[0], role=roles[0], manufacturer=manufacturers[0], name='Inventory Item 1', label='A', part_id='1001', serial='ABC', asset_tag='1001', discovered=True, status=ModuleStatusChoices.STATUS_ACTIVE, description='First', component=components[0]),
- InventoryItem(device=devices[1], role=roles[1], manufacturer=manufacturers[1], name='Inventory Item 2', label='B', part_id='1002', serial='DEF', asset_tag='1002', discovered=True, status=ModuleStatusChoices.STATUS_PLANNED, description='Second', component=components[1]),
- InventoryItem(device=devices[2], role=roles[2], manufacturer=manufacturers[2], name='Inventory Item 3', label='C', part_id='1003', serial='GHI', asset_tag='1003', discovered=False, status=ModuleStatusChoices.STATUS_FAILED, description='Third', component=components[2]),
+ InventoryItem(
+ device=devices[0],
+ role=roles[0],
+ manufacturer=manufacturers[0],
+ name='Inventory Item 1',
+ label='A',
+ part_id='1001',
+ serial='ABC',
+ asset_tag='1001',
+ discovered=True,
+ status=ModuleStatusChoices.STATUS_ACTIVE,
+ description='First',
+ component=components[0],
+ ),
+ InventoryItem(
+ device=devices[1],
+ role=roles[1],
+ manufacturer=manufacturers[1],
+ name='Inventory Item 2',
+ label='B',
+ part_id='1002',
+ serial='DEF',
+ asset_tag='1002',
+ discovered=True,
+ status=ModuleStatusChoices.STATUS_PLANNED,
+ description='Second',
+ component=components[1],
+ ),
+ InventoryItem(
+ device=devices[2],
+ role=roles[2],
+ manufacturer=manufacturers[2],
+ name='Inventory Item 3',
+ label='C',
+ part_id='1003',
+ serial='GHI',
+ asset_tag='1003',
+ discovered=False,
+ status=ModuleStatusChoices.STATUS_FAILED,
+ description='Third',
+ component=components[2],
+ ),
)
for i in inventory_items:
i.save()
@@ -5127,12 +5681,60 @@ class CableTestCase(TestCase, ChangeLoggedFilterSetTests):
role = DeviceRole.objects.create(name='Device Role 1', slug='device-role-1')
devices = (
- Device(name='Device 1', device_type=device_type, role=role, site=sites[0], rack=racks[0], location=locations[0], position=1),
- Device(name='Device 2', device_type=device_type, role=role, site=sites[0], rack=racks[0], location=locations[0], position=2),
- Device(name='Device 3', device_type=device_type, role=role, site=sites[1], rack=racks[1], location=locations[1], position=1),
- Device(name='Device 4', device_type=device_type, role=role, site=sites[1], rack=racks[1], location=locations[1], position=2),
- Device(name='Device 5', device_type=device_type, role=role, site=sites[2], rack=racks[2], location=locations[2], position=1),
- Device(name='Device 6', device_type=device_type, role=role, site=sites[2], rack=racks[2], location=locations[2], position=2),
+ Device(
+ name='Device 1',
+ device_type=device_type,
+ role=role,
+ site=sites[0],
+ rack=racks[0],
+ location=locations[0],
+ position=1,
+ ),
+ Device(
+ name='Device 2',
+ device_type=device_type,
+ role=role,
+ site=sites[0],
+ rack=racks[0],
+ location=locations[0],
+ position=2,
+ ),
+ Device(
+ name='Device 3',
+ device_type=device_type,
+ role=role,
+ site=sites[1],
+ rack=racks[1],
+ location=locations[1],
+ position=1,
+ ),
+ Device(
+ name='Device 4',
+ device_type=device_type,
+ role=role,
+ site=sites[1],
+ rack=racks[1],
+ location=locations[1],
+ position=2,
+ ),
+ Device(
+ name='Device 5',
+ device_type=device_type,
+ role=role,
+ site=sites[2],
+ rack=racks[2],
+ location=locations[2],
+ position=1,
+ ),
+ Device(
+ name='Device 6',
+ device_type=device_type,
+ role=role,
+ site=sites[2],
+ rack=racks[2],
+ location=locations[2],
+ position=2,
+ ),
)
Device.objects.bulk_create(devices)
diff --git a/netbox/dcim/tests/test_models.py b/netbox/dcim/tests/test_models.py
index 8d43d67ea..ff1eddd56 100644
--- a/netbox/dcim/tests/test_models.py
+++ b/netbox/dcim/tests/test_models.py
@@ -612,14 +612,31 @@ class DeviceTestCase(TestCase):
device_role = DeviceRole.objects.first()
# Device with site only should pass
- Device(name='device1', site=sites[0], device_type=device_type, role=device_role).full_clean()
+ Device(
+ name='device1',
+ site=sites[0],
+ device_type=device_type,
+ role=device_role
+ ).full_clean()
# Device with site, cluster non-site should pass
- Device(name='device1', site=sites[0], device_type=device_type, role=device_role, cluster=clusters[2]).full_clean()
+ Device(
+ name='device1',
+ site=sites[0],
+ device_type=device_type,
+ role=device_role,
+ cluster=clusters[2]
+ ).full_clean()
# Device with mismatched site & cluster should fail
with self.assertRaises(ValidationError):
- Device(name='device1', site=sites[0], device_type=device_type, role=device_role, cluster=clusters[1]).full_clean()
+ Device(
+ name='device1',
+ site=sites[0],
+ device_type=device_type,
+ role=device_role,
+ cluster=clusters[1]
+ ).full_clean()
class ModuleBayTestCase(TestCase):
@@ -636,7 +653,9 @@ class ModuleBayTestCase(TestCase):
# Create a CustomField with a default value & assign it to all component models
location = Location.objects.create(name='Location 1', slug='location-1', site=site)
rack = Rack.objects.create(name='Rack 1', site=site)
- device = Device.objects.create(name='Device 1', device_type=device_type, role=device_role, site=site, location=location, rack=rack)
+ device = Device.objects.create(
+ name='Device 1', device_type=device_type, role=device_role, site=site, location=location, rack=rack
+ )
module_bays = (
ModuleBay(device=device, name='Module Bay 1', label='A', description='First'),
diff --git a/netbox/dcim/tests/test_views.py b/netbox/dcim/tests/test_views.py
index 9850081d1..c2c5b6a01 100644
--- a/netbox/dcim/tests/test_views.py
+++ b/netbox/dcim/tests/test_views.py
@@ -196,9 +196,27 @@ class LocationTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
tenant = Tenant.objects.create(name='Tenant 1', slug='tenant-1')
locations = (
- Location(name='Location 1', slug='location-1', site=site, status=LocationStatusChoices.STATUS_ACTIVE, tenant=tenant),
- Location(name='Location 2', slug='location-2', site=site, status=LocationStatusChoices.STATUS_ACTIVE, tenant=tenant),
- Location(name='Location 3', slug='location-3', site=site, status=LocationStatusChoices.STATUS_ACTIVE, tenant=tenant),
+ Location(
+ name='Location 1',
+ slug='location-1',
+ site=site,
+ status=LocationStatusChoices.STATUS_ACTIVE,
+ tenant=tenant,
+ ),
+ Location(
+ name='Location 2',
+ slug='location-2',
+ site=site,
+ status=LocationStatusChoices.STATUS_ACTIVE,
+ tenant=tenant,
+ ),
+ Location(
+ name='Location 3',
+ slug='location-3',
+ site=site,
+ status=LocationStatusChoices.STATUS_ACTIVE,
+ tenant=tenant,
+ ),
)
for location in locations:
location.save()
@@ -346,9 +364,24 @@ class RackTypeTestCase(ViewTestCases.PrimaryObjectViewTestCase):
Manufacturer.objects.bulk_create(manufacturers)
rack_types = (
- RackType(manufacturer=manufacturers[0], model='RackType 1', slug='rack-type-1', form_factor=RackFormFactorChoices.TYPE_CABINET,),
- RackType(manufacturer=manufacturers[0], model='RackType 2', slug='rack-type-2', form_factor=RackFormFactorChoices.TYPE_CABINET,),
- RackType(manufacturer=manufacturers[0], model='RackType 3', slug='rack-type-3', form_factor=RackFormFactorChoices.TYPE_CABINET,),
+ RackType(
+ manufacturer=manufacturers[0],
+ model='RackType 1',
+ slug='rack-type-1',
+ form_factor=RackFormFactorChoices.TYPE_CABINET,
+ ),
+ RackType(
+ manufacturer=manufacturers[0],
+ model='RackType 2',
+ slug='rack-type-2',
+ form_factor=RackFormFactorChoices.TYPE_CABINET,
+ ),
+ RackType(
+ manufacturer=manufacturers[0],
+ model='RackType 3',
+ slug='rack-type-3',
+ form_factor=RackFormFactorChoices.TYPE_CABINET,
+ ),
)
RackType.objects.bulk_create(rack_types)
@@ -692,9 +725,15 @@ class DeviceTypeTestCase(
)
RearPortTemplate.objects.bulk_create(rear_ports)
front_ports = (
- FrontPortTemplate(device_type=devicetype, name='Front Port 1', rear_port=rear_ports[0], rear_port_position=1),
- FrontPortTemplate(device_type=devicetype, name='Front Port 2', rear_port=rear_ports[1], rear_port_position=1),
- FrontPortTemplate(device_type=devicetype, name='Front Port 3', rear_port=rear_ports[2], rear_port_position=1),
+ FrontPortTemplate(
+ device_type=devicetype, name='Front Port 1', rear_port=rear_ports[0], rear_port_position=1
+ ),
+ FrontPortTemplate(
+ device_type=devicetype, name='Front Port 2', rear_port=rear_ports[1], rear_port_position=1
+ ),
+ FrontPortTemplate(
+ device_type=devicetype, name='Front Port 3', rear_port=rear_ports[2], rear_port_position=1
+ ),
)
FrontPortTemplate.objects.bulk_create(front_ports)
@@ -1081,9 +1120,15 @@ class ModuleTypeTestCase(
)
RearPortTemplate.objects.bulk_create(rear_ports)
front_ports = (
- FrontPortTemplate(module_type=moduletype, name='Front Port 1', rear_port=rear_ports[0], rear_port_position=1),
- FrontPortTemplate(module_type=moduletype, name='Front Port 2', rear_port=rear_ports[1], rear_port_position=1),
- FrontPortTemplate(module_type=moduletype, name='Front Port 3', rear_port=rear_ports[2], rear_port_position=1),
+ FrontPortTemplate(
+ module_type=moduletype, name='Front Port 1', rear_port=rear_ports[0], rear_port_position=1
+ ),
+ FrontPortTemplate(
+ module_type=moduletype, name='Front Port 2', rear_port=rear_ports[1], rear_port_position=1
+ ),
+ FrontPortTemplate(
+ module_type=moduletype, name='Front Port 3', rear_port=rear_ports[2], rear_port_position=1
+ ),
)
FrontPortTemplate.objects.bulk_create(front_ports)
@@ -1453,11 +1498,19 @@ class FrontPortTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCas
)
RearPortTemplate.objects.bulk_create(rearports)
- FrontPortTemplate.objects.bulk_create((
- FrontPortTemplate(device_type=devicetype, name='Front Port Template 1', rear_port=rearports[0], rear_port_position=1),
- FrontPortTemplate(device_type=devicetype, name='Front Port Template 2', rear_port=rearports[1], rear_port_position=1),
- FrontPortTemplate(device_type=devicetype, name='Front Port Template 3', rear_port=rearports[2], rear_port_position=1),
- ))
+ FrontPortTemplate.objects.bulk_create(
+ (
+ FrontPortTemplate(
+ device_type=devicetype, name='Front Port Template 1', rear_port=rearports[0], rear_port_position=1
+ ),
+ FrontPortTemplate(
+ device_type=devicetype, name='Front Port Template 2', rear_port=rearports[1], rear_port_position=1
+ ),
+ FrontPortTemplate(
+ device_type=devicetype, name='Front Port Template 3', rear_port=rearports[2], rear_port_position=1
+ ),
+ )
+ )
cls.form_data = {
'device_type': devicetype.pk,
@@ -1550,7 +1603,12 @@ class DeviceBayTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCas
@classmethod
def setUpTestData(cls):
manufacturer = Manufacturer.objects.create(name='Manufacturer 1', slug='manufacturer-1')
- devicetype = DeviceType.objects.create(manufacturer=manufacturer, model='Device Type 1', slug='device-type-1', subdevice_role=SubdeviceRoleChoices.ROLE_PARENT)
+ devicetype = DeviceType.objects.create(
+ manufacturer=manufacturer,
+ model='Device Type 1',
+ slug='device-type-1',
+ subdevice_role=SubdeviceRoleChoices.ROLE_PARENT
+ )
DeviceBayTemplate.objects.bulk_create((
DeviceBayTemplate(device_type=devicetype, name='Device Bay Template 1'),
@@ -1584,12 +1642,20 @@ class InventoryItemTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTes
Manufacturer(name='Manufacturer 2', slug='manufacturer-2'),
)
Manufacturer.objects.bulk_create(manufacturers)
- devicetype = DeviceType.objects.create(manufacturer=manufacturers[0], model='Device Type 1', slug='device-type-1')
+ devicetype = DeviceType.objects.create(
+ manufacturer=manufacturers[0], model='Device Type 1', slug='device-type-1'
+ )
inventory_item_templates = (
- InventoryItemTemplate(device_type=devicetype, name='Inventory Item Template 1', manufacturer=manufacturers[0]),
- InventoryItemTemplate(device_type=devicetype, name='Inventory Item Template 2', manufacturer=manufacturers[0]),
- InventoryItemTemplate(device_type=devicetype, name='Inventory Item Template 3', manufacturer=manufacturers[0]),
+ InventoryItemTemplate(
+ device_type=devicetype, name='Inventory Item Template 1', manufacturer=manufacturers[0]
+ ),
+ InventoryItemTemplate(
+ device_type=devicetype, name='Inventory Item Template 2', manufacturer=manufacturers[0]
+ ),
+ InventoryItemTemplate(
+ device_type=devicetype, name='Inventory Item Template 3', manufacturer=manufacturers[0]
+ ),
)
for item in inventory_item_templates:
item.save()
@@ -1741,9 +1807,30 @@ class DeviceTestCase(ViewTestCases.PrimaryObjectViewTestCase):
Platform.objects.bulk_create(platforms)
devices = (
- Device(name='Device 1', site=sites[0], rack=racks[0], device_type=devicetypes[0], role=roles[0], platform=platforms[0]),
- Device(name='Device 2', site=sites[0], rack=racks[0], device_type=devicetypes[0], role=roles[0], platform=platforms[0]),
- Device(name='Device 3', site=sites[0], rack=racks[0], device_type=devicetypes[0], role=roles[0], platform=platforms[0]),
+ Device(
+ name='Device 1',
+ site=sites[0],
+ rack=racks[0],
+ device_type=devicetypes[0],
+ role=roles[0],
+ platform=platforms[0],
+ ),
+ Device(
+ name='Device 2',
+ site=sites[0],
+ rack=racks[0],
+ device_type=devicetypes[0],
+ role=roles[0],
+ platform=platforms[0],
+ ),
+ Device(
+ name='Device 3',
+ site=sites[0],
+ rack=racks[0],
+ device_type=devicetypes[0],
+ role=roles[0],
+ platform=platforms[0],
+ ),
)
Device.objects.bulk_create(devices)
@@ -1778,10 +1865,22 @@ class DeviceTestCase(ViewTestCases.PrimaryObjectViewTestCase):
}
cls.csv_data = (
- "role,manufacturer,device_type,status,name,site,location,rack,position,face,virtual_chassis,vc_position,vc_priority",
- "Device Role 1,Manufacturer 1,Device Type 1,active,Device 4,Site 1,Location 1,Rack 1,10,front,Virtual Chassis 1,1,10",
- "Device Role 1,Manufacturer 1,Device Type 1,active,Device 5,Site 1,Location 1,Rack 1,20,front,Virtual Chassis 1,2,20",
- "Device Role 1,Manufacturer 1,Device Type 1,active,Device 6,Site 1,Location 1,Rack 1,30,front,Virtual Chassis 1,3,30",
+ (
+ "role,manufacturer,device_type,status,name,site,location,rack,position,face,virtual_chassis,"
+ "vc_position,vc_priority"
+ ),
+ (
+ "Device Role 1,Manufacturer 1,Device Type 1,active,Device 4,Site 1,Location 1,Rack 1,10,front,"
+ "Virtual Chassis 1,1,10"
+ ),
+ (
+ "Device Role 1,Manufacturer 1,Device Type 1,active,Device 5,Site 1,Location 1,Rack 1,20,front,"
+ "Virtual Chassis 1,2,20"
+ ),
+ (
+ "Device Role 1,Manufacturer 1,Device Type 1,active,Device 6,Site 1,Location 1,Rack 1,30,front,"
+ "Virtual Chassis 1,3,30"
+ ),
)
cls.csv_update_data = (
@@ -2884,9 +2983,15 @@ class InventoryItemTestCase(ViewTestCases.DeviceComponentViewTestCase):
)
InventoryItemRole.objects.bulk_create(roles)
- inventory_item1 = InventoryItem.objects.create(device=device, name='Inventory Item 1', role=roles[0], manufacturer=manufacturer)
- inventory_item2 = InventoryItem.objects.create(device=device, name='Inventory Item 2', role=roles[0], manufacturer=manufacturer)
- inventory_item3 = InventoryItem.objects.create(device=device, name='Inventory Item 3', role=roles[0], manufacturer=manufacturer)
+ inventory_item1 = InventoryItem.objects.create(
+ device=device, name='Inventory Item 1', role=roles[0], manufacturer=manufacturer
+ )
+ inventory_item2 = InventoryItem.objects.create(
+ device=device, name='Inventory Item 2', role=roles[0], manufacturer=manufacturer
+ )
+ inventory_item3 = InventoryItem.objects.create(
+ device=device, name='Inventory Item 3', role=roles[0], manufacturer=manufacturer
+ )
tags = create_tags('Alpha', 'Bravo', 'Charlie')
diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py
index f6e7b90be..731034dc1 100644
--- a/netbox/dcim/views.py
+++ b/netbox/dcim/views.py
@@ -244,7 +244,9 @@ class RegionView(GetRelatedModelsMixin, generic.ObjectView):
(Location.objects.restrict(request.user, 'view').filter(site__region__in=regions), 'region_id'),
(Rack.objects.restrict(request.user, 'view').filter(site__region__in=regions), 'region_id'),
(
- Circuit.objects.restrict(request.user, 'view').filter(terminations___region=instance).distinct(),
+ Circuit.objects.restrict(request.user, 'view').filter(
+ terminations___region=instance
+ ).distinct(),
'region_id'
),
),
@@ -335,7 +337,9 @@ class SiteGroupView(GetRelatedModelsMixin, generic.ObjectView):
(Location.objects.restrict(request.user, 'view').filter(site__group__in=groups), 'site_group_id'),
(Rack.objects.restrict(request.user, 'view').filter(site__group__in=groups), 'site_group_id'),
(
- Circuit.objects.restrict(request.user, 'view').filter(terminations___site_group=instance).distinct(),
+ Circuit.objects.restrict(request.user, 'view').filter(
+ terminations___site_group=instance
+ ).distinct(),
'site_group_id'
),
),
@@ -507,7 +511,9 @@ class LocationView(GetRelatedModelsMixin, generic.ObjectView):
[CableTermination],
(
(
- Circuit.objects.restrict(request.user, 'view').filter(terminations___location=instance).distinct(),
+ Circuit.objects.restrict(request.user, 'view').filter(
+ terminations___location=instance
+ ).distinct(),
'location_id'
),
),
@@ -3729,7 +3735,9 @@ class VirtualChassisAddMemberView(ObjectPermissionRequiredMixin, GetReturnURLMix
membership_form.save()
messages.success(request, mark_safe(
- _('Added member {device}').format(url=device.get_absolute_url(), device=escape(device))
+ _('Added member {device}').format(
+ url=device.get_absolute_url(), device=escape(device)
+ )
))
if '_addanother' in request.POST: