Browse Source

Fixed tests

Jeremy Stretch 7 years ago
parent
commit
a75d7079df
2 changed files with 8 additions and 2 deletions
  1. 1 1
      netbox/dcim/models.py
  2. 7 1
      netbox/dcim/tests/test_api.py

+ 1 - 1
netbox/dcim/models.py

@@ -1462,7 +1462,7 @@ class Interface(models.Model):
             self.untagged_vlan = None
 
         # Only "tagged" interfaces may have tagged VLANs assigned. ("tagged all" implies all VLANs are assigned.)
-        if self.mode is not IFACE_MODE_TAGGED:
+        if self.pk and self.mode is not IFACE_MODE_TAGGED:
             self.tagged_vlans.clear()
 
         return super(Interface, self).save(*args, **kwargs)

+ 7 - 1
netbox/dcim/tests/test_api.py

@@ -5,7 +5,9 @@ from django.urls import reverse
 from rest_framework import status
 from rest_framework.test import APITestCase
 
-from dcim.constants import IFACE_FF_1GE_FIXED, IFACE_FF_LAG, SUBDEVICE_ROLE_CHILD, SUBDEVICE_ROLE_PARENT
+from dcim.constants import (
+    IFACE_FF_1GE_FIXED, IFACE_FF_LAG, IFACE_MODE_TAGGED, SUBDEVICE_ROLE_CHILD, SUBDEVICE_ROLE_PARENT,
+)
 from dcim.models import (
     ConsolePort, ConsolePortTemplate, ConsoleServerPort, ConsoleServerPortTemplate, Device, DeviceBay,
     DeviceBayTemplate, DeviceRole, DeviceType, Interface, InterfaceConnection, InterfaceTemplate, Manufacturer,
@@ -2319,6 +2321,7 @@ class InterfaceTest(HttpStatusMixin, APITestCase):
         data = {
             'device': self.device.pk,
             'name': 'Test Interface 4',
+            'mode': IFACE_MODE_TAGGED,
             'tagged_vlans': [self.vlan1.id, self.vlan2.id],
             'untagged_vlan': self.vlan3.id
         }
@@ -2366,18 +2369,21 @@ class InterfaceTest(HttpStatusMixin, APITestCase):
             {
                 'device': self.device.pk,
                 'name': 'Test Interface 4',
+                'mode': IFACE_MODE_TAGGED,
                 'tagged_vlans': [self.vlan1.id],
                 'untagged_vlan': self.vlan2.id,
             },
             {
                 'device': self.device.pk,
                 'name': 'Test Interface 5',
+                'mode': IFACE_MODE_TAGGED,
                 'tagged_vlans': [self.vlan1.id],
                 'untagged_vlan': self.vlan2.id,
             },
             {
                 'device': self.device.pk,
                 'name': 'Test Interface 6',
+                'mode': IFACE_MODE_TAGGED,
                 'tagged_vlans': [self.vlan1.id],
                 'untagged_vlan': self.vlan2.id,
             },