mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Clean up tests
This commit is contained in:
@ -150,7 +150,7 @@ def get_cable_form(a_type, b_type):
|
||||
|
||||
# TODO: Temporary hack to work around list handling limitations with utils.normalize_querydict()
|
||||
for field_name in ('a_terminations', 'b_terminations'):
|
||||
if field_name in kwargs['initial'] and type(kwargs['initial'][field_name]) is not list:
|
||||
if field_name in kwargs.get('initial', {}) and type(kwargs['initial'][field_name]) is not list:
|
||||
kwargs['initial'][field_name] = [kwargs['initial'][field_name]]
|
||||
|
||||
super().__init__(*args, **kwargs)
|
||||
|
@ -99,6 +99,14 @@ class CableType(NetBoxObjectType):
|
||||
return self.length_unit or None
|
||||
|
||||
|
||||
class CableTerminationType(NetBoxObjectType):
|
||||
|
||||
class Meta:
|
||||
model = models.CableTermination
|
||||
fields = '__all__'
|
||||
filterset_class = filtersets.CableTerminationFilterSet
|
||||
|
||||
|
||||
class ConsolePortType(ComponentObjectType):
|
||||
|
||||
class Meta:
|
||||
|
@ -521,14 +521,6 @@ class CableTestCase(TestCase):
|
||||
self.assertIsNone(interface2.cable)
|
||||
self.assertIsNone(interface2._link_peer)
|
||||
|
||||
def test_cabletermination_deletion(self):
|
||||
"""
|
||||
When a CableTermination object is deleted, its attached Cable (if any) must also be deleted.
|
||||
"""
|
||||
self.interface1.delete()
|
||||
cable = Cable.objects.filter(pk=self.cable.pk).first()
|
||||
self.assertIsNone(cable)
|
||||
|
||||
def test_cable_validates_compatible_types(self):
|
||||
"""
|
||||
The clean method should have a check to ensure only compatible port types can be connected by a cable
|
||||
@ -538,14 +530,6 @@ class CableTestCase(TestCase):
|
||||
with self.assertRaises(ValidationError):
|
||||
cable.clean()
|
||||
|
||||
def test_cable_cannot_have_the_same_terminination_on_both_ends(self):
|
||||
"""
|
||||
A cable cannot be made with the same A and B side terminations
|
||||
"""
|
||||
cable = Cable(a_terminations=[self.interface1], b_terminations=[self.interface1])
|
||||
with self.assertRaises(ValidationError):
|
||||
cable.clean()
|
||||
|
||||
def test_cable_front_port_cannot_connect_to_corresponding_rear_port(self):
|
||||
"""
|
||||
A cable cannot connect a front port to its corresponding rear port
|
||||
@ -554,15 +538,6 @@ class CableTestCase(TestCase):
|
||||
with self.assertRaises(ValidationError):
|
||||
cable.clean()
|
||||
|
||||
def test_cable_cannot_terminate_to_an_existing_connection(self):
|
||||
"""
|
||||
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(a_terminations=[self.interface2], b_terminations=[self.interface1])
|
||||
with self.assertRaises(ValidationError):
|
||||
cable.clean()
|
||||
|
||||
def test_cable_cannot_terminate_to_a_provider_network_circuittermination(self):
|
||||
"""
|
||||
Neither side of a cable can be terminated to a CircuitTermination which is attached to a ProviderNetwork
|
||||
|
@ -2631,11 +2631,10 @@ class CableTestCase(
|
||||
|
||||
interface_ct = ContentType.objects.get_for_model(Interface)
|
||||
cls.form_data = {
|
||||
# TODO: Revisit this limitation
|
||||
# Changing terminations not supported when editing an existing Cable
|
||||
'termination_a_type': interface_ct.pk,
|
||||
'termination_a_id': interfaces[0].pk,
|
||||
'termination_b_type': interface_ct.pk,
|
||||
'termination_b_id': interfaces[3].pk,
|
||||
'a_terminations': interfaces[0].pk,
|
||||
'b_terminations': interfaces[3].pk,
|
||||
'type': CableTypeChoices.TYPE_CAT6,
|
||||
'status': LinkStatusChoices.STATUS_PLANNED,
|
||||
'label': 'Label',
|
||||
|
Reference in New Issue
Block a user