mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-25 08:46:10 -06:00
7961 update tests remove redundant code
This commit is contained in:
parent
969c6dbae8
commit
0be3747c01
@ -921,7 +921,6 @@ class L2VPNTerminationTestCase(
|
||||
device = create_test_device('Device 1')
|
||||
interface = Interface.objects.create(name='Interface 1', device=device, type='1000baset')
|
||||
l2vpn = L2VPN.objects.create(name='L2VPN 1', slug='l2vpn-1', type=L2VPNTypeChoices.TYPE_VXLAN, identifier=650001)
|
||||
l2vpn2 = L2VPN.objects.create(name='L2VPN 2', slug='l2vpn-2', type=L2VPNTypeChoices.TYPE_VXLAN, identifier=650002)
|
||||
|
||||
vlans = (
|
||||
VLAN(name='Vlan 1', vid=1001),
|
||||
|
@ -331,7 +331,7 @@ class BulkImportView(GetReturnURLMixin, BaseMultiObjectView):
|
||||
|
||||
def _update_objects(self, form, request, headers, records):
|
||||
from utilities.forms import CSVModelChoiceField
|
||||
new_objs = []
|
||||
updated_objs = []
|
||||
|
||||
ids = [int(record["id"]) for record in records]
|
||||
qs = self.queryset.model.objects.filter(id__in=ids)
|
||||
@ -356,13 +356,13 @@ class BulkImportView(GetReturnURLMixin, BaseMultiObjectView):
|
||||
|
||||
if obj_form.is_valid():
|
||||
obj = self._save_obj(obj_form, request)
|
||||
new_objs.append(obj)
|
||||
updated_objs.append(obj)
|
||||
else:
|
||||
for field, err in obj_form.errors.items():
|
||||
form.add_error('csv', f'Row {row} {field}: {err[0]}')
|
||||
raise ValidationError("")
|
||||
|
||||
return new_objs
|
||||
return updated_objs
|
||||
|
||||
def _create_objects(self, form, request, headers, records):
|
||||
new_objs = []
|
||||
|
@ -592,9 +592,10 @@ class ViewTestCases:
|
||||
|
||||
@override_settings(EXEMPT_VIEW_PERMISSIONS=['*'])
|
||||
def test_bulk_update_objects_with_permission(self):
|
||||
if not self.csv_update_data:
|
||||
if not hasattr(self, 'csv_update_data'):
|
||||
raise NotImplementedError("The test must define csv_update_data.")
|
||||
|
||||
initial_count = self._get_queryset().count()
|
||||
data = {
|
||||
'csv': self._get_csv_data(),
|
||||
}
|
||||
@ -608,7 +609,7 @@ class ViewTestCases:
|
||||
obj_perm.users.add(self.user)
|
||||
obj_perm.object_types.add(ContentType.objects.get_for_model(self.model))
|
||||
|
||||
self.assertHttpStatus(self.client.post(self._get_url('import'), data), 200)
|
||||
# self.assertHttpStatus(self.client.post(self._get_url('import'), data), 200)
|
||||
count = self._get_queryset().count()
|
||||
|
||||
# Now try update the data
|
||||
|
Loading…
Reference in New Issue
Block a user