mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-14 15:52:18 -06:00
Update Cable instantiations to match new signature
This commit is contained in:
@@ -465,7 +465,7 @@ class CableTestCase(TestCase):
|
||||
self.interface1 = Interface.objects.create(device=self.device1, name='eth0')
|
||||
self.interface2 = Interface.objects.create(device=self.device2, name='eth0')
|
||||
self.interface3 = Interface.objects.create(device=self.device2, name='eth1')
|
||||
self.cable = Cable(termination_a=self.interface1, termination_b=self.interface2)
|
||||
self.cable = Cable(a_terminations=[self.interface1], b_terminations=[self.interface2])
|
||||
self.cable.save()
|
||||
|
||||
self.power_port1 = PowerPort.objects.create(device=self.device2, name='psu1')
|
||||
@@ -536,7 +536,7 @@ class CableTestCase(TestCase):
|
||||
The clean method should have a check to ensure only compatible port types can be connected by a cable
|
||||
"""
|
||||
# An interface cannot be connected to a power port
|
||||
cable = Cable(termination_a=self.interface1, termination_b=self.power_port1)
|
||||
cable = Cable(a_terminations=[self.interface1], b_terminations=[self.power_port1])
|
||||
with self.assertRaises(ValidationError):
|
||||
cable.clean()
|
||||
|
||||
@@ -544,7 +544,7 @@ class CableTestCase(TestCase):
|
||||
"""
|
||||
A cable cannot be made with the same A and B side terminations
|
||||
"""
|
||||
cable = Cable(termination_a=self.interface1, termination_b=self.interface1)
|
||||
cable = Cable(a_terminations=[self.interface1], b_terminations=[self.interface1])
|
||||
with self.assertRaises(ValidationError):
|
||||
cable.clean()
|
||||
|
||||
@@ -552,7 +552,7 @@ class CableTestCase(TestCase):
|
||||
"""
|
||||
A cable cannot connect a front port to its corresponding rear port
|
||||
"""
|
||||
cable = Cable(termination_a=self.front_port1, termination_b=self.rear_port1)
|
||||
cable = Cable(a_terminations=[self.front_port1], b_terminations=[self.rear_port1])
|
||||
with self.assertRaises(ValidationError):
|
||||
cable.clean()
|
||||
|
||||
@@ -561,7 +561,7 @@ class CableTestCase(TestCase):
|
||||
Either side of a cable cannot be terminated when that side already has a connection
|
||||
"""
|
||||
# Try to create a cable with the same interface terminations
|
||||
cable = Cable(termination_a=self.interface2, termination_b=self.interface1)
|
||||
cable = Cable(a_terminations=[self.interface2], b_terminations=[self.interface1])
|
||||
with self.assertRaises(ValidationError):
|
||||
cable.clean()
|
||||
|
||||
@@ -569,7 +569,7 @@ class CableTestCase(TestCase):
|
||||
"""
|
||||
Neither side of a cable can be terminated to a CircuitTermination which is attached to a ProviderNetwork
|
||||
"""
|
||||
cable = Cable(termination_a=self.interface3, termination_b=self.circuittermination3)
|
||||
cable = Cable(a_terminations=[self.interface3], b_terminations=[self.circuittermination3])
|
||||
with self.assertRaises(ValidationError):
|
||||
cable.clean()
|
||||
|
||||
@@ -578,36 +578,36 @@ class CableTestCase(TestCase):
|
||||
Test various combinations of RearPort connections.
|
||||
"""
|
||||
# Connecting a single-position RearPort to a multi-position RearPort is ok
|
||||
Cable(termination_a=self.rear_port1, termination_b=self.rear_port2).full_clean()
|
||||
Cable(a_terminations=[self.rear_port1], b_terminations=[self.rear_port2]).full_clean()
|
||||
|
||||
# Connecting a single-position RearPort to an Interface is ok
|
||||
Cable(termination_a=self.rear_port1, termination_b=self.interface3).full_clean()
|
||||
Cable(a_terminations=[self.rear_port1], b_terminations=[self.interface3]).full_clean()
|
||||
|
||||
# Connecting a single-position RearPort to a CircuitTermination is ok
|
||||
Cable(termination_a=self.rear_port1, termination_b=self.circuittermination1).full_clean()
|
||||
Cable(a_terminations=[self.rear_port1], b_terminations=[self.circuittermination1]).full_clean()
|
||||
|
||||
# Connecting a multi-position RearPort to another RearPort with the same number of positions is ok
|
||||
Cable(termination_a=self.rear_port3, termination_b=self.rear_port4).full_clean()
|
||||
Cable(a_terminations=[self.rear_port3], b_terminations=[self.rear_port4]).full_clean()
|
||||
|
||||
# Connecting a multi-position RearPort to an Interface is ok
|
||||
Cable(termination_a=self.rear_port2, termination_b=self.interface3).full_clean()
|
||||
Cable(a_terminations=[self.rear_port2], b_terminations=[self.interface3]).full_clean()
|
||||
|
||||
# Connecting a multi-position RearPort to a CircuitTermination is ok
|
||||
Cable(termination_a=self.rear_port2, termination_b=self.circuittermination1).full_clean()
|
||||
Cable(a_terminations=[self.rear_port2], b_terminations=[self.circuittermination1]).full_clean()
|
||||
|
||||
# Connecting a two-position RearPort to a three-position RearPort is NOT ok
|
||||
with self.assertRaises(
|
||||
ValidationError,
|
||||
msg='Connecting a 2-position RearPort to a 3-position RearPort should fail'
|
||||
):
|
||||
Cable(termination_a=self.rear_port2, termination_b=self.rear_port3).full_clean()
|
||||
Cable(a_terminations=[self.rear_port2], b_terminations=[self.rear_port3]).full_clean()
|
||||
|
||||
def test_cable_cannot_terminate_to_a_virtual_interface(self):
|
||||
"""
|
||||
A cable cannot terminate to a virtual interface
|
||||
"""
|
||||
virtual_interface = Interface(device=self.device1, name="V1", type=InterfaceTypeChoices.TYPE_VIRTUAL)
|
||||
cable = Cable(termination_a=self.interface2, termination_b=virtual_interface)
|
||||
cable = Cable(a_terminations=[self.interface2], b_terminations=[virtual_interface])
|
||||
with self.assertRaises(ValidationError):
|
||||
cable.clean()
|
||||
|
||||
@@ -616,6 +616,6 @@ class CableTestCase(TestCase):
|
||||
A cable cannot terminate to a wireless interface
|
||||
"""
|
||||
wireless_interface = Interface(device=self.device1, name="W1", type=InterfaceTypeChoices.TYPE_80211A)
|
||||
cable = Cable(termination_a=self.interface2, termination_b=wireless_interface)
|
||||
cable = Cable(a_terminations=[self.interface2], b_terminations=[wireless_interface])
|
||||
with self.assertRaises(ValidationError):
|
||||
cable.clean()
|
||||
|
||||
Reference in New Issue
Block a user