mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-29 11:56:25 -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',
|
||||
}
|
||||
|
||||
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):
|
||||
rear_port = DynamicModelChoiceField(
|
||||
|
@ -1135,6 +1135,7 @@ class TagTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
'l2vpn',
|
||||
'l2vpntermination',
|
||||
'location',
|
||||
'macaddress',
|
||||
'manufacturer',
|
||||
'module',
|
||||
'modulebay',
|
||||
|
@ -4,7 +4,7 @@ from django.core.exceptions import ValidationError
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
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 ipam.models import IPAddress, VLAN, VLANGroup, VLANTranslationPolicy, VRF
|
||||
from netbox.forms import NetBoxModelForm
|
||||
@ -370,6 +370,14 @@ class VMInterfaceForm(InterfaceCommonForm, VMComponentForm):
|
||||
'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):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user