mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-25 00:36:11 -06:00
7961 update tests
This commit is contained in:
parent
bfe485cac9
commit
63df2dc08c
@ -576,7 +576,7 @@ class PowerOutletCSVForm(NetBoxModelCSVForm):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
# 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:
|
||||
device = self.fields['device'].to_python(self.data['device'])
|
||||
except forms.ValidationError:
|
||||
@ -711,7 +711,7 @@ class FrontPortCSVForm(NetBoxModelCSVForm):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
# 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:
|
||||
device = self.fields['device'].to_python(self.data['device'])
|
||||
except forms.ValidationError:
|
||||
@ -782,7 +782,7 @@ class DeviceBayCSVForm(NetBoxModelCSVForm):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
# 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:
|
||||
device = self.fields['device'].to_python(self.data['device'])
|
||||
except forms.ValidationError:
|
||||
|
@ -394,7 +394,7 @@ class RackTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
||||
)
|
||||
|
||||
cls.csv_update_data = (
|
||||
"name, status",
|
||||
"name,status",
|
||||
f"Rack 7,{RackStatusChoices.STATUS_DEPRECATED}",
|
||||
f"Rack 8,{RackStatusChoices.STATUS_DEPRECATED}",
|
||||
f"Rack 9,{RackStatusChoices.STATUS_DEPRECATED}",
|
||||
|
@ -298,13 +298,13 @@ class IPAddressCSVForm(NetBoxModelCSVForm):
|
||||
def save(self, *args, **kwargs):
|
||||
|
||||
# Set interface assignment
|
||||
if self.cleaned_data['interface']:
|
||||
if self.cleaned_data.get('interface'):
|
||||
self.instance.assigned_object = self.cleaned_data['interface']
|
||||
|
||||
ipaddress = super().save(*args, **kwargs)
|
||||
|
||||
# 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']
|
||||
if self.instance.address.version == 4:
|
||||
parent.primary_ip4 = ipaddress
|
||||
|
@ -615,7 +615,7 @@ class ViewTestCases:
|
||||
obj_perm.object_types.add(ContentType.objects.get_for_model(self.model))
|
||||
|
||||
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
|
||||
array, csv_data = self._get_update_csv_data(start_id)
|
||||
|
Loading…
Reference in New Issue
Block a user