7961 update tests

This commit is contained in:
Arthur 2022-10-21 11:03:06 -07:00
parent bfe485cac9
commit 63df2dc08c
4 changed files with 7 additions and 7 deletions

View File

@ -576,7 +576,7 @@ class PowerOutletCSVForm(NetBoxModelCSVForm):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
# Limit PowerPort choices to those belonging to this device (or VC master) # Limit PowerPort choices to those belonging to this device (or VC master)
if self.is_bound: if self.is_bound and 'device' in self.data:
try: try:
device = self.fields['device'].to_python(self.data['device']) device = self.fields['device'].to_python(self.data['device'])
except forms.ValidationError: except forms.ValidationError:
@ -711,7 +711,7 @@ class FrontPortCSVForm(NetBoxModelCSVForm):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
# Limit RearPort choices to those belonging to this device (or VC master) # Limit RearPort choices to those belonging to this device (or VC master)
if self.is_bound: if self.is_bound and 'device' in self.data:
try: try:
device = self.fields['device'].to_python(self.data['device']) device = self.fields['device'].to_python(self.data['device'])
except forms.ValidationError: except forms.ValidationError:
@ -782,7 +782,7 @@ class DeviceBayCSVForm(NetBoxModelCSVForm):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
# Limit installed device choices to devices of the correct type and location # Limit installed device choices to devices of the correct type and location
if self.is_bound: if self.is_bound and 'device' in self.data:
try: try:
device = self.fields['device'].to_python(self.data['device']) device = self.fields['device'].to_python(self.data['device'])
except forms.ValidationError: except forms.ValidationError:

View File

@ -298,13 +298,13 @@ class IPAddressCSVForm(NetBoxModelCSVForm):
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
# Set interface assignment # Set interface assignment
if self.cleaned_data['interface']: if self.cleaned_data.get('interface'):
self.instance.assigned_object = self.cleaned_data['interface'] self.instance.assigned_object = self.cleaned_data['interface']
ipaddress = super().save(*args, **kwargs) ipaddress = super().save(*args, **kwargs)
# Set as primary for device/VM # Set as primary for device/VM
if self.cleaned_data['is_primary']: if self.cleaned_data.get('is_primary'):
parent = self.cleaned_data['device'] or self.cleaned_data['virtual_machine'] parent = self.cleaned_data['device'] or self.cleaned_data['virtual_machine']
if self.instance.address.version == 4: if self.instance.address.version == 4:
parent.primary_ip4 = ipaddress parent.primary_ip4 = ipaddress

View File

@ -615,7 +615,7 @@ class ViewTestCases:
obj_perm.object_types.add(ContentType.objects.get_for_model(self.model)) 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)
start_id = self._get_queryset().first().id start_id = self._get_queryset().order_by('id').first().id
# Now try update the data # Now try update the data
array, csv_data = self._get_update_csv_data(start_id) array, csv_data = self._get_update_csv_data(start_id)