|
@@ -54,6 +54,26 @@ class MACAddressTestCase(TestCase):
|
|
|
cls.interface.primary_mac_address = cls.mac_a
|
|
cls.interface.primary_mac_address = cls.mac_a
|
|
|
cls.interface.save()
|
|
cls.interface.save()
|
|
|
|
|
|
|
|
|
|
+ @tag('regression') # Ref: #23617
|
|
|
|
|
+ def test_primary_mac_assignment_on_interface_creation_records_prechange(self):
|
|
|
|
|
+ mac = MACAddress.objects.create(mac_address='1234567890cd')
|
|
|
|
|
+ request = RequestFactory().get('/')
|
|
|
|
|
+ request.id = uuid.uuid4()
|
|
|
|
|
+ request.user = User.objects.create_user(username='testuser')
|
|
|
|
|
+
|
|
|
|
|
+ with event_tracking(request):
|
|
|
|
|
+ interface = Interface.objects.create(
|
|
|
|
|
+ device=self.interface.device, name='Interface 2', type=InterfaceTypeChoices.TYPE_1GE_FIXED,
|
|
|
|
|
+ primary_mac_address=mac
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ change = ObjectChange.objects.get(
|
|
|
|
|
+ changed_object_type=ObjectType.objects.get_for_model(MACAddress),
|
|
|
|
|
+ changed_object_id=mac.pk,
|
|
|
|
|
+ )
|
|
|
|
|
+ self.assertIsNone(change.prechange_data['assigned_object_id'])
|
|
|
|
|
+ self.assertEqual(change.postchange_data['assigned_object_id'], interface.pk)
|
|
|
|
|
+
|
|
|
@tag('regression')
|
|
@tag('regression')
|
|
|
def test_clean_will_not_allow_removal_of_assigned_object_if_primary(self):
|
|
def test_clean_will_not_allow_removal_of_assigned_object_if_primary(self):
|
|
|
self.mac_a.assigned_object = None
|
|
self.mac_a.assigned_object = None
|
|
@@ -1325,6 +1345,29 @@ class DeviceBayTestCase(TestCase):
|
|
|
self.assertIn('installed_device', cm.exception.message_dict)
|
|
self.assertIn('installed_device', cm.exception.message_dict)
|
|
|
self.assertIn('disabled device bay', str(cm.exception.message_dict['installed_device']))
|
|
self.assertIn('disabled device bay', str(cm.exception.message_dict['installed_device']))
|
|
|
|
|
|
|
|
|
|
+ @tag('regression') # Ref: #23617
|
|
|
|
|
+ def test_moving_parent_device_records_child_prechange(self):
|
|
|
|
|
+ DeviceBay.objects.create(device=self.parent_device, name='Bay 1', installed_device=self.child_device)
|
|
|
|
|
+ old_site = self.parent_device.site
|
|
|
|
|
+ new_site = Site.objects.create(name='Test Site 2', slug='test-site-2')
|
|
|
|
|
+ request = RequestFactory().get('/')
|
|
|
|
|
+ request.id = uuid.uuid4()
|
|
|
|
|
+ request.user = User.objects.create_user(username='testuser')
|
|
|
|
|
+
|
|
|
|
|
+ with event_tracking(request):
|
|
|
|
|
+ parent = Device.objects.get(pk=self.parent_device.pk)
|
|
|
|
|
+ parent.snapshot()
|
|
|
|
|
+ parent.site = new_site
|
|
|
|
|
+ parent.save()
|
|
|
|
|
+
|
|
|
|
|
+ change = ObjectChange.objects.get(
|
|
|
|
|
+ changed_object_type=ObjectType.objects.get_for_model(Device),
|
|
|
|
|
+ changed_object_id=self.child_device.pk,
|
|
|
|
|
+ action=ObjectChangeActionChoices.ACTION_UPDATE,
|
|
|
|
|
+ )
|
|
|
|
|
+ self.assertEqual(change.prechange_data['site'], old_site.pk)
|
|
|
|
|
+ self.assertEqual(change.postchange_data['site'], new_site.pk)
|
|
|
|
|
+
|
|
|
def test_can_disable_bay_with_existing_device(self):
|
|
def test_can_disable_bay_with_existing_device(self):
|
|
|
"""
|
|
"""
|
|
|
Test that disabling a bay that already has a device installed does NOT raise an error
|
|
Test that disabling a bay that already has a device installed does NOT raise an error
|
|
@@ -3403,6 +3446,17 @@ class CableDisconnectChangeLoggingTestCase(TestCase):
|
|
|
action=ObjectChangeActionChoices.ACTION_UPDATE,
|
|
action=ObjectChangeActionChoices.ACTION_UPDATE,
|
|
|
).order_by('time')
|
|
).order_by('time')
|
|
|
|
|
|
|
|
|
|
+ @tag('regression') # Ref: #23617
|
|
|
|
|
+ def test_cable_creation_records_termination_prechange(self):
|
|
|
|
|
+ cable = self._connect(self.interface1, self.interface2)
|
|
|
|
|
+
|
|
|
|
|
+ # The update recording the terminations follows the creation of the Cable itself
|
|
|
|
|
+ change = self._updates(cable).get()
|
|
|
|
|
+ self.assertEqual(change.prechange_data['a_terminations'], [])
|
|
|
|
|
+ self.assertEqual(change.prechange_data['b_terminations'], [])
|
|
|
|
|
+ self.assertEqual(len(change.postchange_data['a_terminations']), 1)
|
|
|
|
|
+ self.assertEqual(len(change.postchange_data['b_terminations']), 1)
|
|
|
|
|
+
|
|
|
@tag('regression') # Ref: netbox-branching#631
|
|
@tag('regression') # Ref: netbox-branching#631
|
|
|
def test_cable_deletion_records_disconnect(self):
|
|
def test_cable_deletion_records_disconnect(self):
|
|
|
cable = self._connect(self.interface1, self.interface2)
|
|
cable = self._connect(self.interface1, self.interface2)
|
|
@@ -3480,6 +3534,7 @@ class CableDisconnectChangeLoggingTestCase(TestCase):
|
|
|
request = self._request()
|
|
request = self._request()
|
|
|
with event_tracking(request):
|
|
with event_tracking(request):
|
|
|
cable = Cable.objects.get(pk=cable_pk)
|
|
cable = Cable.objects.get(pk=cable_pk)
|
|
|
|
|
+ cable.snapshot()
|
|
|
cable.b_terminations = [self.interface3]
|
|
cable.b_terminations = [self.interface3]
|
|
|
cable.save()
|
|
cable.save()
|
|
|
|
|
|