Closes #20564: Many-to-many pass-through port mappings (#20851)

This commit is contained in:
Jeremy Stretch
2025-12-09 12:17:17 -05:00
committed by GitHub
parent 97d0a16fd4
commit 17d8f78ae3
35 changed files with 2512 additions and 941 deletions

View File

@@ -444,13 +444,19 @@ class DeviceTestCase(TestCase):
)
rearport.save()
FrontPortTemplate(
frontport = FrontPortTemplate(
device_type=device_type,
name='Front Port 1',
type=PortTypeChoices.TYPE_8P8C,
)
frontport.save()
PortTemplateMapping.objects.create(
device_type=device_type,
front_port=frontport,
rear_port=rearport,
rear_port_position=2
).save()
rear_port_position=2,
)
ModuleBayTemplate(
device_type=device_type,
@@ -528,11 +534,12 @@ class DeviceTestCase(TestCase):
device=device,
name='Front Port 1',
type=PortTypeChoices.TYPE_8P8C,
rear_port=rearport,
rear_port_position=2
positions=1
)
self.assertEqual(frontport.cf['cf1'], 'foo')
self.assertTrue(PortMapping.objects.filter(front_port=frontport, rear_port=rearport).exists())
modulebay = ModuleBay.objects.get(
device=device,
name='Module Bay 1'
@@ -881,12 +888,18 @@ class CableTestCase(TestCase):
)
RearPort.objects.bulk_create(rear_ports)
front_ports = (
FrontPort(device=patch_panel, name='FP1', type='8p8c', rear_port=rear_ports[0], rear_port_position=1),
FrontPort(device=patch_panel, name='FP2', type='8p8c', rear_port=rear_ports[1], rear_port_position=1),
FrontPort(device=patch_panel, name='FP3', type='8p8c', rear_port=rear_ports[2], rear_port_position=1),
FrontPort(device=patch_panel, name='FP4', type='8p8c', rear_port=rear_ports[3], rear_port_position=1),
FrontPort(device=patch_panel, name='FP1', type='8p8c'),
FrontPort(device=patch_panel, name='FP2', type='8p8c'),
FrontPort(device=patch_panel, name='FP3', type='8p8c'),
FrontPort(device=patch_panel, name='FP4', type='8p8c'),
)
FrontPort.objects.bulk_create(front_ports)
PortMapping.objects.bulk_create([
PortMapping(device=patch_panel, front_port=front_ports[0], rear_port=rear_ports[0]),
PortMapping(device=patch_panel, front_port=front_ports[1], rear_port=rear_ports[1]),
PortMapping(device=patch_panel, front_port=front_ports[2], rear_port=rear_ports[2]),
PortMapping(device=patch_panel, front_port=front_ports[3], rear_port=rear_ports[3]),
])
provider = Provider.objects.create(name='Provider 1', slug='provider-1')
provider_network = ProviderNetwork.objects.create(name='Provider Network 1', provider=provider)