mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-30 04:16:24 -06:00
Fix tests on single-object forms
This commit is contained in:
parent
f64c941f65
commit
dfaa354140
@ -1538,6 +1538,14 @@ class InterfaceForm(InterfaceCommonForm, ModularDeviceComponentForm):
|
|||||||
'mode': '802.1Q Mode',
|
'mode': '802.1Q Mode',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def clean_mac_address(self):
|
||||||
|
return MACAddress.objects.create(mac_address=self.cleaned_data['mac_address'])
|
||||||
|
|
||||||
|
def save(self, commit=True):
|
||||||
|
result = super().save(commit=commit)
|
||||||
|
self.instance.mac_addresses.add(self.cleaned_data['mac_address'])
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
class FrontPortForm(ModularDeviceComponentForm):
|
class FrontPortForm(ModularDeviceComponentForm):
|
||||||
rear_port = DynamicModelChoiceField(
|
rear_port = DynamicModelChoiceField(
|
||||||
|
@ -1135,6 +1135,7 @@ class TagTestCase(TestCase, ChangeLoggedFilterSetTests):
|
|||||||
'l2vpn',
|
'l2vpn',
|
||||||
'l2vpntermination',
|
'l2vpntermination',
|
||||||
'location',
|
'location',
|
||||||
|
'macaddress',
|
||||||
'manufacturer',
|
'manufacturer',
|
||||||
'module',
|
'module',
|
||||||
'modulebay',
|
'modulebay',
|
||||||
|
@ -4,7 +4,7 @@ from django.core.exceptions import ValidationError
|
|||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from dcim.forms.common import InterfaceCommonForm
|
from dcim.forms.common import InterfaceCommonForm
|
||||||
from dcim.models import Device, DeviceRole, Platform, Rack, Region, Site, SiteGroup
|
from dcim.models import Device, DeviceRole, MACAddress, Platform, Rack, Region, Site, SiteGroup
|
||||||
from extras.models import ConfigTemplate
|
from extras.models import ConfigTemplate
|
||||||
from ipam.models import IPAddress, VLAN, VLANGroup, VLANTranslationPolicy, VRF
|
from ipam.models import IPAddress, VLAN, VLANGroup, VLANTranslationPolicy, VRF
|
||||||
from netbox.forms import NetBoxModelForm
|
from netbox.forms import NetBoxModelForm
|
||||||
@ -370,6 +370,14 @@ class VMInterfaceForm(InterfaceCommonForm, VMComponentForm):
|
|||||||
'mode': HTMXSelect(),
|
'mode': HTMXSelect(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def clean_mac_address(self):
|
||||||
|
return MACAddress.objects.create(mac_address=self.cleaned_data['mac_address'])
|
||||||
|
|
||||||
|
def save(self, commit=True):
|
||||||
|
result = super().save(commit=commit)
|
||||||
|
self.instance.mac_addresses.add(self.cleaned_data['mac_address'])
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
class VirtualDiskForm(VMComponentForm):
|
class VirtualDiskForm(VMComponentForm):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user