From 4da58163852796c2f20d8e59e35c33d652c9de3f Mon Sep 17 00:00:00 2001 From: Martin Hauser Date: Wed, 23 Jul 2025 22:11:42 +0200 Subject: [PATCH] docs(dcim): Update comments explaining indent for CSV import Improved the inline comments to clarify the rationale behind allowing devices with duplicate names on different sites during CSV bulk import. --- netbox/dcim/tests/test_views.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/netbox/dcim/tests/test_views.py b/netbox/dcim/tests/test_views.py index 8755930b2..5e41b37f7 100644 --- a/netbox/dcim/tests/test_views.py +++ b/netbox/dcim/tests/test_views.py @@ -3276,10 +3276,16 @@ class CableTestCase( role = DeviceRole.objects.create(name='Device Role 1', slug='device-role-1') vc = VirtualChassis.objects.create(name='Virtual Chassis') + # NOTE: By design, NetBox now allows for the creation of devices with the same name if they belong to + # different sites. + # The CSV test below demonstrates that devices with identical names on different sites can be created + # and referenced successfully. devices = ( + # Create 'Device 1' assigned to 'Site 1' Device(name='Device 1', site=sites[0], device_type=devicetype, role=role), Device(name='Device 2', site=sites[0], device_type=devicetype, role=role), Device(name='Device 3', site=sites[0], device_type=devicetype, role=role), + # Create 'Device 1' assigned to 'Site 2' (allowed since the site is different) Device(name='Device 1', site=sites[1], device_type=devicetype, role=role), ) Device.objects.bulk_create(devices) @@ -3331,6 +3337,8 @@ class CableTestCase( 'tags': [t.pk for t in tags], } + # Ensure that CSV bulk import supports assigning terminations from parent devices that share + # the same device name, provided those devices belong to different sites. cls.csv_data = ( "side_a_site,side_a_device,side_a_type,side_a_name,side_b_site,side_b_device,side_b_type,side_b_name", "Site 1,Device 3,dcim.interface,Interface 1,Site 2,Device 1,dcim.interface,Interface 1",