1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #10201: Fix AssertionError exception when removing some terminations from an existing cable

This commit is contained in:
jeremystretch
2023-01-11 14:42:25 -05:00
parent 1e54eee631
commit 758c5347fb
3 changed files with 45 additions and 0 deletions

View File

@ -12,6 +12,7 @@
### Bug Fixes ### Bug Fixes
* [#10201](https://github.com/netbox-community/netbox/issues/10201) - Fix AssertionError exception when removing some terminations from an existing cable
* [#11210](https://github.com/netbox-community/netbox/issues/11210) - Fix ValueError exception when attempting to bulk import cables attached to occupied terminations * [#11210](https://github.com/netbox-community/netbox/issues/11210) - Fix ValueError exception when attempting to bulk import cables attached to occupied terminations
* [#11340](https://github.com/netbox-community/netbox/issues/11340) - Avoid flagging cable termination changes erroneously * [#11340](https://github.com/netbox-community/netbox/issues/11340) - Avoid flagging cable termination changes erroneously
* [#11379](https://github.com/netbox-community/netbox/issues/11379) - Fix TypeError exception when bulk editing custom date fields * [#11379](https://github.com/netbox-community/netbox/issues/11379) - Fix TypeError exception when bulk editing custom date fields

View File

@ -124,6 +124,9 @@ def nullify_connected_endpoints(instance, **kwargs):
model.objects.filter(pk=instance.termination_id).update(cable=None, cable_end='') model.objects.filter(pk=instance.termination_id).update(cable=None, cable_end='')
for cablepath in CablePath.objects.filter(_nodes__contains=instance.cable): for cablepath in CablePath.objects.filter(_nodes__contains=instance.cable):
# Remove the deleted CableTermination if it's one of the path's originating nodes
if instance.termination in cablepath.origins:
cablepath.origins.remove(instance.termination)
cablepath.retrace() cablepath.retrace()

View File

@ -1804,3 +1804,44 @@ class CablePathTestCase(TestCase):
is_active=True is_active=True
) )
self.assertEqual(CablePath.objects.count(), 2) self.assertEqual(CablePath.objects.count(), 2)
def test_303_remove_termination_from_existing_cable(self):
"""
[IF1] --C1-- [IF2]
[IF3]
"""
interface1 = Interface.objects.create(device=self.device, name='Interface 1')
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
interface3 = Interface.objects.create(device=self.device, name='Interface 3')
# Create cables 1
cable1 = Cable(
a_terminations=[interface1],
b_terminations=[interface2, interface3]
)
cable1.save()
self.assertPathExists(
(interface1, cable1, [interface2, interface3]),
is_complete=True,
is_active=True
)
self.assertPathExists(
([interface2, interface3], cable1, interface1),
is_complete=True,
is_active=True
)
# Remove the termination to interface 3
cable1 = Cable.objects.first()
cable1.b_terminations = [interface2]
cable1.save()
self.assertPathExists(
(interface1, cable1, interface2),
is_complete=True,
is_active=True
)
self.assertPathExists(
(interface2, cable1, interface1),
is_complete=True,
is_active=True
)