From 7d048b38e8f649486361e817fccbe938c9fe15a9 Mon Sep 17 00:00:00 2001 From: Arthur Date: Wed, 16 Aug 2023 15:50:20 -0700 Subject: [PATCH] 11617 fix test cases - fix bulk import for L2VPNTerminationTestCase --- netbox/ipam/forms/bulk_import.py | 6 ++++-- netbox/ipam/tests/test_views.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/netbox/ipam/forms/bulk_import.py b/netbox/ipam/forms/bulk_import.py index 3bce26249..785390e2d 100644 --- a/netbox/ipam/forms/bulk_import.py +++ b/netbox/ipam/forms/bulk_import.py @@ -548,9 +548,11 @@ class L2VPNTerminationImportForm(NetBoxModelImportForm): if self.cleaned_data.get('device') and self.cleaned_data.get('virtual_machine'): raise ValidationError('Cannot import device and VM interface terminations simultaneously.') - if not (self.cleaned_data.get('interface') or self.cleaned_data.get('vlan')): + if not self.instance and not (self.cleaned_data.get('interface') or self.cleaned_data.get('vlan')): raise ValidationError('Each termination must specify either an interface or a VLAN.') if self.cleaned_data.get('interface') and self.cleaned_data.get('vlan'): raise ValidationError('Cannot assign both an interface and a VLAN.') - self.instance.assigned_object = self.cleaned_data.get('interface') or self.cleaned_data.get('vlan') + # if this is an update we might not have interface or vlan in the form data + if self.cleaned_data.get('interface') or self.cleaned_data.get('vlan'): + self.instance.assigned_object = self.cleaned_data.get('interface') or self.cleaned_data.get('vlan') diff --git a/netbox/ipam/tests/test_views.py b/netbox/ipam/tests/test_views.py index 7fe8f104d..c9128c0f6 100644 --- a/netbox/ipam/tests/test_views.py +++ b/netbox/ipam/tests/test_views.py @@ -1032,7 +1032,7 @@ class L2VPNTerminationTestCase( ViewTestCases.EditObjectViewTestCase, ViewTestCases.DeleteObjectViewTestCase, ViewTestCases.ListObjectsViewTestCase, - # ViewTestCases.BulkImportObjectsViewTestCase, + ViewTestCases.BulkImportObjectsViewTestCase, ViewTestCases.BulkDeleteObjectsViewTestCase, ):