mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-24 08:25:17 -06:00
Continued work on #10247
This commit is contained in:
parent
4988c7b7d2
commit
623a7e9a2c
@ -3,7 +3,7 @@ from django import forms
|
|||||||
from dcim.models import *
|
from dcim.models import *
|
||||||
from extras.forms import CustomFieldsMixin
|
from extras.forms import CustomFieldsMixin
|
||||||
from extras.models import Tag
|
from extras.models import Tag
|
||||||
from utilities.forms import DynamicModelMultipleChoiceField, ExpandableNameField, form_from_model
|
from utilities.forms import BootstrapMixin, DynamicModelMultipleChoiceField, ExpandableNameField, form_from_model
|
||||||
from .object_create import ComponentCreateForm
|
from .object_create import ComponentCreateForm
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
@ -24,7 +24,7 @@ __all__ = (
|
|||||||
# Device components
|
# Device components
|
||||||
#
|
#
|
||||||
|
|
||||||
class DeviceBulkAddComponentForm(CustomFieldsMixin, ComponentCreateForm):
|
class DeviceBulkAddComponentForm(BootstrapMixin, CustomFieldsMixin, ComponentCreateForm):
|
||||||
pk = forms.ModelMultipleChoiceField(
|
pk = forms.ModelMultipleChoiceField(
|
||||||
queryset=Device.objects.all(),
|
queryset=Device.objects.all(),
|
||||||
widget=forms.MultipleHiddenInput()
|
widget=forms.MultipleHiddenInput()
|
||||||
@ -44,7 +44,7 @@ class ConsolePortBulkCreateForm(
|
|||||||
DeviceBulkAddComponentForm
|
DeviceBulkAddComponentForm
|
||||||
):
|
):
|
||||||
model = ConsolePort
|
model = ConsolePort
|
||||||
field_order = ('name_pattern', 'label_pattern', 'type', 'mark_connected', 'description', 'tags')
|
field_order = ('name', 'label', 'type', 'mark_connected', 'description', 'tags')
|
||||||
|
|
||||||
|
|
||||||
class ConsoleServerPortBulkCreateForm(
|
class ConsoleServerPortBulkCreateForm(
|
||||||
@ -52,7 +52,7 @@ class ConsoleServerPortBulkCreateForm(
|
|||||||
DeviceBulkAddComponentForm
|
DeviceBulkAddComponentForm
|
||||||
):
|
):
|
||||||
model = ConsoleServerPort
|
model = ConsoleServerPort
|
||||||
field_order = ('name_pattern', 'label_pattern', 'type', 'speed', 'description', 'tags')
|
field_order = ('name', 'label', 'type', 'speed', 'description', 'tags')
|
||||||
|
|
||||||
|
|
||||||
class PowerPortBulkCreateForm(
|
class PowerPortBulkCreateForm(
|
||||||
@ -60,7 +60,7 @@ class PowerPortBulkCreateForm(
|
|||||||
DeviceBulkAddComponentForm
|
DeviceBulkAddComponentForm
|
||||||
):
|
):
|
||||||
model = PowerPort
|
model = PowerPort
|
||||||
field_order = ('name_pattern', 'label_pattern', 'type', 'maximum_draw', 'allocated_draw', 'description', 'tags')
|
field_order = ('name', 'label', 'type', 'maximum_draw', 'allocated_draw', 'description', 'tags')
|
||||||
|
|
||||||
|
|
||||||
class PowerOutletBulkCreateForm(
|
class PowerOutletBulkCreateForm(
|
||||||
@ -68,7 +68,7 @@ class PowerOutletBulkCreateForm(
|
|||||||
DeviceBulkAddComponentForm
|
DeviceBulkAddComponentForm
|
||||||
):
|
):
|
||||||
model = PowerOutlet
|
model = PowerOutlet
|
||||||
field_order = ('name_pattern', 'label_pattern', 'type', 'feed_leg', 'description', 'tags')
|
field_order = ('name', 'label', 'type', 'feed_leg', 'description', 'tags')
|
||||||
|
|
||||||
|
|
||||||
class InterfaceBulkCreateForm(
|
class InterfaceBulkCreateForm(
|
||||||
@ -79,7 +79,7 @@ class InterfaceBulkCreateForm(
|
|||||||
):
|
):
|
||||||
model = Interface
|
model = Interface
|
||||||
field_order = (
|
field_order = (
|
||||||
'name_pattern', 'label_pattern', 'type', 'enabled', 'speed', 'duplex', 'mtu', 'mgmt_only', 'poe_mode',
|
'name', 'label', 'type', 'enabled', 'speed', 'duplex', 'mtu', 'mgmt_only', 'poe_mode',
|
||||||
'poe_type', 'mark_connected', 'description', 'tags',
|
'poe_type', 'mark_connected', 'description', 'tags',
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -96,12 +96,12 @@ class RearPortBulkCreateForm(
|
|||||||
DeviceBulkAddComponentForm
|
DeviceBulkAddComponentForm
|
||||||
):
|
):
|
||||||
model = RearPort
|
model = RearPort
|
||||||
field_order = ('name_pattern', 'label_pattern', 'type', 'positions', 'mark_connected', 'description', 'tags')
|
field_order = ('name', 'label', 'type', 'positions', 'mark_connected', 'description', 'tags')
|
||||||
|
|
||||||
|
|
||||||
class ModuleBayBulkCreateForm(DeviceBulkAddComponentForm):
|
class ModuleBayBulkCreateForm(DeviceBulkAddComponentForm):
|
||||||
model = ModuleBay
|
model = ModuleBay
|
||||||
field_order = ('name_pattern', 'label_pattern', 'position_pattern', 'description', 'tags')
|
field_order = ('name', 'label', 'position_pattern', 'description', 'tags')
|
||||||
|
|
||||||
position_pattern = ExpandableNameField(
|
position_pattern = ExpandableNameField(
|
||||||
label='Position',
|
label='Position',
|
||||||
@ -112,7 +112,7 @@ class ModuleBayBulkCreateForm(DeviceBulkAddComponentForm):
|
|||||||
|
|
||||||
class DeviceBayBulkCreateForm(DeviceBulkAddComponentForm):
|
class DeviceBayBulkCreateForm(DeviceBulkAddComponentForm):
|
||||||
model = DeviceBay
|
model = DeviceBay
|
||||||
field_order = ('name_pattern', 'label_pattern', 'description', 'tags')
|
field_order = ('name', 'label', 'description', 'tags')
|
||||||
|
|
||||||
|
|
||||||
class InventoryItemBulkCreateForm(
|
class InventoryItemBulkCreateForm(
|
||||||
@ -121,6 +121,6 @@ class InventoryItemBulkCreateForm(
|
|||||||
):
|
):
|
||||||
model = InventoryItem
|
model = InventoryItem
|
||||||
field_order = (
|
field_order = (
|
||||||
'name_pattern', 'label_pattern', 'role', 'manufacturer', 'part_id', 'serial', 'asset_tag', 'discovered',
|
'name', 'label', 'role', 'manufacturer', 'part_id', 'serial', 'asset_tag', 'discovered',
|
||||||
'description', 'tags',
|
'description', 'tags',
|
||||||
)
|
)
|
||||||
|
@ -79,23 +79,38 @@ class ComponentCreateForm(forms.Form):
|
|||||||
#
|
#
|
||||||
|
|
||||||
class ConsolePortTemplateCreateForm(ComponentCreateForm, model_forms.ConsolePortTemplateForm):
|
class ConsolePortTemplateCreateForm(ComponentCreateForm, model_forms.ConsolePortTemplateForm):
|
||||||
pass
|
field_order = ('device_type', 'name', 'label')
|
||||||
|
|
||||||
|
class Meta(model_forms.ConsolePortTemplateForm.Meta):
|
||||||
|
exclude = ('name', 'label')
|
||||||
|
|
||||||
|
|
||||||
class ConsoleServerPortTemplateCreateForm(ComponentCreateForm, model_forms.ConsoleServerPortTemplateForm):
|
class ConsoleServerPortTemplateCreateForm(ComponentCreateForm, model_forms.ConsoleServerPortTemplateForm):
|
||||||
pass
|
field_order = ('device_type', 'name', 'label')
|
||||||
|
|
||||||
|
class Meta(model_forms.ConsoleServerPortTemplateForm.Meta):
|
||||||
|
exclude = ('name', 'label')
|
||||||
|
|
||||||
|
|
||||||
class PowerPortTemplateCreateForm(ComponentCreateForm, model_forms.PowerPortTemplateForm):
|
class PowerPortTemplateCreateForm(ComponentCreateForm, model_forms.PowerPortTemplateForm):
|
||||||
pass
|
field_order = ('device_type', 'name', 'label')
|
||||||
|
|
||||||
|
class Meta(model_forms.PowerPortTemplateForm.Meta):
|
||||||
|
exclude = ('name', 'label')
|
||||||
|
|
||||||
|
|
||||||
class PowerOutletTemplateCreateForm(ComponentCreateForm, model_forms.PowerOutletTemplateForm):
|
class PowerOutletTemplateCreateForm(ComponentCreateForm, model_forms.PowerOutletTemplateForm):
|
||||||
pass
|
field_order = ('device_type', 'name', 'label')
|
||||||
|
|
||||||
|
class Meta(model_forms.PowerOutletTemplateForm.Meta):
|
||||||
|
exclude = ('name', 'label')
|
||||||
|
|
||||||
|
|
||||||
class InterfaceTemplateCreateForm(ComponentCreateForm, model_forms.InterfaceTemplateForm):
|
class InterfaceTemplateCreateForm(ComponentCreateForm, model_forms.InterfaceTemplateForm):
|
||||||
pass
|
field_order = ('device_type', 'name', 'label')
|
||||||
|
|
||||||
|
class Meta(model_forms.InterfaceTemplateForm.Meta):
|
||||||
|
exclude = ('name', 'label')
|
||||||
|
|
||||||
|
|
||||||
class FrontPortTemplateCreateForm(ComponentCreateForm, model_forms.FrontPortTemplateForm):
|
class FrontPortTemplateCreateForm(ComponentCreateForm, model_forms.FrontPortTemplateForm):
|
||||||
@ -104,6 +119,10 @@ class FrontPortTemplateCreateForm(ComponentCreateForm, model_forms.FrontPortTemp
|
|||||||
label='Rear ports',
|
label='Rear ports',
|
||||||
help_text='Select one rear port assignment for each front port being created.',
|
help_text='Select one rear port assignment for each front port being created.',
|
||||||
)
|
)
|
||||||
|
field_order = ('device_type', 'name', 'label')
|
||||||
|
|
||||||
|
class Meta(model_forms.FrontPortTemplateForm.Meta):
|
||||||
|
exclude = ('name', 'label')
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
@ -149,11 +168,17 @@ class FrontPortTemplateCreateForm(ComponentCreateForm, model_forms.FrontPortTemp
|
|||||||
|
|
||||||
|
|
||||||
class RearPortTemplateCreateForm(ComponentCreateForm, model_forms.RearPortTemplateForm):
|
class RearPortTemplateCreateForm(ComponentCreateForm, model_forms.RearPortTemplateForm):
|
||||||
pass
|
field_order = ('device_type', 'name', 'label')
|
||||||
|
|
||||||
|
class Meta(model_forms.RearPortTemplateForm.Meta):
|
||||||
|
exclude = ('name', 'label')
|
||||||
|
|
||||||
|
|
||||||
class DeviceBayTemplateCreateForm(ComponentCreateForm, model_forms.DeviceBayTemplateForm):
|
class DeviceBayTemplateCreateForm(ComponentCreateForm, model_forms.DeviceBayTemplateForm):
|
||||||
pass
|
field_order = ('device_type', 'name', 'label')
|
||||||
|
|
||||||
|
class Meta(model_forms.DeviceBayTemplateForm.Meta):
|
||||||
|
exclude = ('name', 'label')
|
||||||
|
|
||||||
|
|
||||||
class ModuleBayTemplateCreateForm(ComponentCreateForm, model_forms.ModuleBayTemplateForm):
|
class ModuleBayTemplateCreateForm(ComponentCreateForm, model_forms.ModuleBayTemplateForm):
|
||||||
@ -162,10 +187,17 @@ class ModuleBayTemplateCreateForm(ComponentCreateForm, model_forms.ModuleBayTemp
|
|||||||
required=False,
|
required=False,
|
||||||
help_text='Alphanumeric ranges are supported. (Must match the number of names being created.)'
|
help_text='Alphanumeric ranges are supported. (Must match the number of names being created.)'
|
||||||
)
|
)
|
||||||
|
field_order = ('device_type', 'name', 'label')
|
||||||
|
|
||||||
|
class Meta(model_forms.ModuleBayTemplateForm.Meta):
|
||||||
|
exclude = ('name', 'label')
|
||||||
|
|
||||||
|
|
||||||
class InventoryItemTemplateCreateForm(ComponentCreateForm, model_forms.InventoryItemTemplateForm):
|
class InventoryItemTemplateCreateForm(ComponentCreateForm, model_forms.InventoryItemTemplateForm):
|
||||||
pass
|
field_order = ('device_type', 'name', 'label')
|
||||||
|
|
||||||
|
class Meta(model_forms.InventoryItemTemplateForm.Meta):
|
||||||
|
exclude = ('name', 'label')
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -173,23 +205,38 @@ class InventoryItemTemplateCreateForm(ComponentCreateForm, model_forms.Inventory
|
|||||||
#
|
#
|
||||||
|
|
||||||
class ConsolePortCreateForm(ComponentCreateForm, model_forms.ConsolePortForm):
|
class ConsolePortCreateForm(ComponentCreateForm, model_forms.ConsolePortForm):
|
||||||
pass
|
field_order = ('device', 'name', 'label')
|
||||||
|
|
||||||
|
class Meta(model_forms.ConsolePortForm.Meta):
|
||||||
|
exclude = ('name', 'label')
|
||||||
|
|
||||||
|
|
||||||
class ConsoleServerPortCreateForm(ComponentCreateForm, model_forms.ConsoleServerPortForm):
|
class ConsoleServerPortCreateForm(ComponentCreateForm, model_forms.ConsoleServerPortForm):
|
||||||
pass
|
field_order = ('device', 'name', 'label')
|
||||||
|
|
||||||
|
class Meta(model_forms.ConsoleServerPortForm.Meta):
|
||||||
|
exclude = ('name', 'label')
|
||||||
|
|
||||||
|
|
||||||
class PowerPortCreateForm(ComponentCreateForm, model_forms.PowerPortForm):
|
class PowerPortCreateForm(ComponentCreateForm, model_forms.PowerPortForm):
|
||||||
pass
|
field_order = ('device', 'name', 'label')
|
||||||
|
|
||||||
|
class Meta(model_forms.PowerPortForm.Meta):
|
||||||
|
exclude = ('name', 'label')
|
||||||
|
|
||||||
|
|
||||||
class PowerOutletCreateForm(ComponentCreateForm, model_forms.PowerOutletForm):
|
class PowerOutletCreateForm(ComponentCreateForm, model_forms.PowerOutletForm):
|
||||||
pass
|
field_order = ('device', 'name', 'label')
|
||||||
|
|
||||||
|
class Meta(model_forms.PowerOutletForm.Meta):
|
||||||
|
exclude = ('name', 'label')
|
||||||
|
|
||||||
|
|
||||||
class InterfaceCreateForm(ComponentCreateForm, model_forms.InterfaceForm):
|
class InterfaceCreateForm(ComponentCreateForm, model_forms.InterfaceForm):
|
||||||
pass
|
field_order = ('device', 'name', 'label')
|
||||||
|
|
||||||
|
class Meta(model_forms.InterfaceForm.Meta):
|
||||||
|
exclude = ('name', 'label')
|
||||||
|
|
||||||
|
|
||||||
class FrontPortCreateForm(ComponentCreateForm, model_forms.FrontPortForm):
|
class FrontPortCreateForm(ComponentCreateForm, model_forms.FrontPortForm):
|
||||||
@ -198,6 +245,10 @@ class FrontPortCreateForm(ComponentCreateForm, model_forms.FrontPortForm):
|
|||||||
label='Rear ports',
|
label='Rear ports',
|
||||||
help_text='Select one rear port assignment for each front port being created.',
|
help_text='Select one rear port assignment for each front port being created.',
|
||||||
)
|
)
|
||||||
|
field_order = ('device', 'name', 'label')
|
||||||
|
|
||||||
|
class Meta(model_forms.FrontPortForm.Meta):
|
||||||
|
exclude = ('name', 'label')
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
@ -236,11 +287,17 @@ class FrontPortCreateForm(ComponentCreateForm, model_forms.FrontPortForm):
|
|||||||
|
|
||||||
|
|
||||||
class RearPortCreateForm(ComponentCreateForm, model_forms.RearPortForm):
|
class RearPortCreateForm(ComponentCreateForm, model_forms.RearPortForm):
|
||||||
pass
|
field_order = ('device', 'name', 'label')
|
||||||
|
|
||||||
|
class Meta(model_forms.RearPortForm.Meta):
|
||||||
|
exclude = ('name', 'label')
|
||||||
|
|
||||||
|
|
||||||
class DeviceBayCreateForm(ComponentCreateForm, model_forms.DeviceBayForm):
|
class DeviceBayCreateForm(ComponentCreateForm, model_forms.DeviceBayForm):
|
||||||
pass
|
field_order = ('device', 'name', 'label')
|
||||||
|
|
||||||
|
class Meta(model_forms.DeviceBayForm.Meta):
|
||||||
|
exclude = ('name', 'label')
|
||||||
|
|
||||||
|
|
||||||
class ModuleBayCreateForm(ComponentCreateForm, model_forms.ModuleBayForm):
|
class ModuleBayCreateForm(ComponentCreateForm, model_forms.ModuleBayForm):
|
||||||
@ -249,11 +306,17 @@ class ModuleBayCreateForm(ComponentCreateForm, model_forms.ModuleBayForm):
|
|||||||
required=False,
|
required=False,
|
||||||
help_text='Alphanumeric ranges are supported. (Must match the number of names being created.)'
|
help_text='Alphanumeric ranges are supported. (Must match the number of names being created.)'
|
||||||
)
|
)
|
||||||
|
field_order = ('device', 'name', 'label')
|
||||||
|
|
||||||
|
class Meta(model_forms.ModuleBayForm.Meta):
|
||||||
|
exclude = ('name', 'label')
|
||||||
|
|
||||||
|
|
||||||
class InventoryItemCreateForm(ComponentCreateForm):
|
class InventoryItemCreateForm(ComponentCreateForm, model_forms.InventoryItemForm):
|
||||||
# Device is assigned by the model form
|
field_order = ('device', 'name', 'label')
|
||||||
field_order = ('name_pattern', 'label_pattern')
|
|
||||||
|
class Meta(model_forms.InventoryItemForm.Meta):
|
||||||
|
exclude = ('name', 'label')
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -239,7 +239,7 @@ INTERFACE_BUTTONS = """
|
|||||||
<li><a class="dropdown-item" href="{% url 'dcim:inventoryitem_add' %}?device={{ record.device_id }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">Inventory Item</a></li>
|
<li><a class="dropdown-item" href="{% url 'dcim:inventoryitem_add' %}?device={{ record.device_id }}&component_type={{ record|content_type_id }}&component_id={{ record.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">Inventory Item</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.dcim.add_interface %}
|
{% if perms.dcim.add_interface %}
|
||||||
<li><a class="dropdown-item" href="{% url 'dcim:interface_add' %}?device={{ record.device_id }}&parent={{ record.pk }}&name_pattern={{ record.name }}.&type=virtual&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">Child Interface</a></li>
|
<li><a class="dropdown-item" href="{% url 'dcim:interface_add' %}?device={{ record.device_id }}&parent={{ record.pk }}&name={{ record.name }}.&type=virtual&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">Child Interface</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.ipam.add_l2vpntermination %}
|
{% if perms.ipam.add_l2vpntermination %}
|
||||||
<li><a class="dropdown-item" href="{% url 'ipam:l2vpntermination_add' %}?device={{ object.pk }}&interface={{ record.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">L2VPN Termination</a></li>
|
<li><a class="dropdown-item" href="{% url 'ipam:l2vpntermination_add' %}?device={{ object.pk }}&interface={{ record.pk }}&return_url={% url 'dcim:device_interfaces' pk=object.pk %}">L2VPN Termination</a></li>
|
||||||
|
@ -129,8 +129,8 @@ class LabelTestCase(TestCase):
|
|||||||
"""
|
"""
|
||||||
interface_data = {
|
interface_data = {
|
||||||
'device': self.device.pk,
|
'device': self.device.pk,
|
||||||
'name_pattern': 'eth[0-9]',
|
'name': 'eth[0-9]',
|
||||||
'label_pattern': 'Interface[0-9]',
|
'label': 'Interface[0-9]',
|
||||||
}
|
}
|
||||||
form = InterfaceCreateForm(interface_data)
|
form = InterfaceCreateForm(interface_data)
|
||||||
|
|
||||||
@ -142,10 +142,10 @@ class LabelTestCase(TestCase):
|
|||||||
"""
|
"""
|
||||||
bad_interface_data = {
|
bad_interface_data = {
|
||||||
'device': self.device.pk,
|
'device': self.device.pk,
|
||||||
'name_pattern': 'eth[0-9]',
|
'name': 'eth[0-9]',
|
||||||
'label_pattern': 'Interface[0-1]',
|
'label': 'Interface[0-1]',
|
||||||
}
|
}
|
||||||
form = InterfaceCreateForm(bad_interface_data)
|
form = InterfaceCreateForm(bad_interface_data)
|
||||||
|
|
||||||
self.assertFalse(form.is_valid())
|
self.assertFalse(form.is_valid())
|
||||||
self.assertIn('label_pattern', form.errors)
|
self.assertIn('label', form.errors)
|
||||||
|
@ -1082,6 +1082,7 @@ front-ports:
|
|||||||
|
|
||||||
class ConsolePortTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCase):
|
class ConsolePortTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCase):
|
||||||
model = ConsolePortTemplate
|
model = ConsolePortTemplate
|
||||||
|
validation_excluded_fields = ('name', 'label')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
@ -1106,7 +1107,7 @@ class ConsolePortTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestC
|
|||||||
|
|
||||||
cls.bulk_create_data = {
|
cls.bulk_create_data = {
|
||||||
'device_type': devicetypes[1].pk,
|
'device_type': devicetypes[1].pk,
|
||||||
'name_pattern': 'Console Port Template [4-6]',
|
'name': 'Console Port Template [4-6]',
|
||||||
'type': ConsolePortTypeChoices.TYPE_RJ45,
|
'type': ConsolePortTypeChoices.TYPE_RJ45,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1117,6 +1118,7 @@ class ConsolePortTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestC
|
|||||||
|
|
||||||
class ConsoleServerPortTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCase):
|
class ConsoleServerPortTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCase):
|
||||||
model = ConsoleServerPortTemplate
|
model = ConsoleServerPortTemplate
|
||||||
|
validation_excluded_fields = ('name', 'label')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
@ -1141,7 +1143,7 @@ class ConsoleServerPortTemplateTestCase(ViewTestCases.DeviceComponentTemplateVie
|
|||||||
|
|
||||||
cls.bulk_create_data = {
|
cls.bulk_create_data = {
|
||||||
'device_type': devicetypes[1].pk,
|
'device_type': devicetypes[1].pk,
|
||||||
'name_pattern': 'Console Server Port Template [4-6]',
|
'name': 'Console Server Port Template [4-6]',
|
||||||
'type': ConsolePortTypeChoices.TYPE_RJ45,
|
'type': ConsolePortTypeChoices.TYPE_RJ45,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1152,6 +1154,7 @@ class ConsoleServerPortTemplateTestCase(ViewTestCases.DeviceComponentTemplateVie
|
|||||||
|
|
||||||
class PowerPortTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCase):
|
class PowerPortTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCase):
|
||||||
model = PowerPortTemplate
|
model = PowerPortTemplate
|
||||||
|
validation_excluded_fields = ('name', 'label')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
@ -1178,7 +1181,7 @@ class PowerPortTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCas
|
|||||||
|
|
||||||
cls.bulk_create_data = {
|
cls.bulk_create_data = {
|
||||||
'device_type': devicetypes[1].pk,
|
'device_type': devicetypes[1].pk,
|
||||||
'name_pattern': 'Power Port Template [4-6]',
|
'name': 'Power Port Template [4-6]',
|
||||||
'type': PowerPortTypeChoices.TYPE_IEC_C14,
|
'type': PowerPortTypeChoices.TYPE_IEC_C14,
|
||||||
'maximum_draw': 100,
|
'maximum_draw': 100,
|
||||||
'allocated_draw': 50,
|
'allocated_draw': 50,
|
||||||
@ -1193,6 +1196,7 @@ class PowerPortTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCas
|
|||||||
|
|
||||||
class PowerOutletTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCase):
|
class PowerOutletTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCase):
|
||||||
model = PowerOutletTemplate
|
model = PowerOutletTemplate
|
||||||
|
validation_excluded_fields = ('name', 'label')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
@ -1220,7 +1224,7 @@ class PowerOutletTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestC
|
|||||||
|
|
||||||
cls.bulk_create_data = {
|
cls.bulk_create_data = {
|
||||||
'device_type': devicetype.pk,
|
'device_type': devicetype.pk,
|
||||||
'name_pattern': 'Power Outlet Template [4-6]',
|
'name': 'Power Outlet Template [4-6]',
|
||||||
'type': PowerOutletTypeChoices.TYPE_IEC_C13,
|
'type': PowerOutletTypeChoices.TYPE_IEC_C13,
|
||||||
'power_port': powerports[0].pk,
|
'power_port': powerports[0].pk,
|
||||||
'feed_leg': PowerOutletFeedLegChoices.FEED_LEG_B,
|
'feed_leg': PowerOutletFeedLegChoices.FEED_LEG_B,
|
||||||
@ -1234,6 +1238,7 @@ class PowerOutletTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestC
|
|||||||
|
|
||||||
class InterfaceTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCase):
|
class InterfaceTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCase):
|
||||||
model = InterfaceTemplate
|
model = InterfaceTemplate
|
||||||
|
validation_excluded_fields = ('name', 'label')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
@ -1259,9 +1264,9 @@ class InterfaceTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCas
|
|||||||
|
|
||||||
cls.bulk_create_data = {
|
cls.bulk_create_data = {
|
||||||
'device_type': devicetypes[1].pk,
|
'device_type': devicetypes[1].pk,
|
||||||
'name_pattern': 'Interface Template [4-6]',
|
'name': 'Interface Template [4-6]',
|
||||||
# Test that a label can be applied to each generated interface templates
|
# Test that a label can be applied to each generated interface templates
|
||||||
'label_pattern': 'Interface Template Label [3-5]',
|
'label': 'Interface Template Label [3-5]',
|
||||||
'type': InterfaceTypeChoices.TYPE_1GE_GBIC,
|
'type': InterfaceTypeChoices.TYPE_1GE_GBIC,
|
||||||
'mgmt_only': True,
|
'mgmt_only': True,
|
||||||
}
|
}
|
||||||
@ -1274,6 +1279,7 @@ class InterfaceTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCas
|
|||||||
|
|
||||||
class FrontPortTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCase):
|
class FrontPortTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCase):
|
||||||
model = FrontPortTemplate
|
model = FrontPortTemplate
|
||||||
|
validation_excluded_fields = ('name', 'label')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
@ -1306,7 +1312,7 @@ class FrontPortTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCas
|
|||||||
|
|
||||||
cls.bulk_create_data = {
|
cls.bulk_create_data = {
|
||||||
'device_type': devicetype.pk,
|
'device_type': devicetype.pk,
|
||||||
'name_pattern': 'Front Port [4-6]',
|
'name': 'Front Port [4-6]',
|
||||||
'type': PortTypeChoices.TYPE_8P8C,
|
'type': PortTypeChoices.TYPE_8P8C,
|
||||||
'rear_port_set': [
|
'rear_port_set': [
|
||||||
'{}:1'.format(rp.pk) for rp in rearports[3:6]
|
'{}:1'.format(rp.pk) for rp in rearports[3:6]
|
||||||
@ -1320,6 +1326,7 @@ class FrontPortTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCas
|
|||||||
|
|
||||||
class RearPortTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCase):
|
class RearPortTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCase):
|
||||||
model = RearPortTemplate
|
model = RearPortTemplate
|
||||||
|
validation_excluded_fields = ('name', 'label')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
@ -1345,7 +1352,7 @@ class RearPortTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCase
|
|||||||
|
|
||||||
cls.bulk_create_data = {
|
cls.bulk_create_data = {
|
||||||
'device_type': devicetypes[1].pk,
|
'device_type': devicetypes[1].pk,
|
||||||
'name_pattern': 'Rear Port Template [4-6]',
|
'name': 'Rear Port Template [4-6]',
|
||||||
'type': PortTypeChoices.TYPE_8P8C,
|
'type': PortTypeChoices.TYPE_8P8C,
|
||||||
'positions': 2,
|
'positions': 2,
|
||||||
}
|
}
|
||||||
@ -1357,6 +1364,7 @@ class RearPortTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCase
|
|||||||
|
|
||||||
class ModuleBayTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCase):
|
class ModuleBayTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCase):
|
||||||
model = ModuleBayTemplate
|
model = ModuleBayTemplate
|
||||||
|
validation_excluded_fields = ('name', 'label')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
@ -1380,7 +1388,7 @@ class ModuleBayTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCas
|
|||||||
|
|
||||||
cls.bulk_create_data = {
|
cls.bulk_create_data = {
|
||||||
'device_type': devicetypes[1].pk,
|
'device_type': devicetypes[1].pk,
|
||||||
'name_pattern': 'Module Bay Template [4-6]',
|
'name': 'Module Bay Template [4-6]',
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.bulk_edit_data = {
|
cls.bulk_edit_data = {
|
||||||
@ -1390,6 +1398,7 @@ class ModuleBayTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCas
|
|||||||
|
|
||||||
class DeviceBayTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCase):
|
class DeviceBayTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCase):
|
||||||
model = DeviceBayTemplate
|
model = DeviceBayTemplate
|
||||||
|
validation_excluded_fields = ('name', 'label')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
@ -1413,7 +1422,7 @@ class DeviceBayTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCas
|
|||||||
|
|
||||||
cls.bulk_create_data = {
|
cls.bulk_create_data = {
|
||||||
'device_type': devicetypes[1].pk,
|
'device_type': devicetypes[1].pk,
|
||||||
'name_pattern': 'Device Bay Template [4-6]',
|
'name': 'Device Bay Template [4-6]',
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.bulk_edit_data = {
|
cls.bulk_edit_data = {
|
||||||
@ -1423,6 +1432,7 @@ class DeviceBayTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCas
|
|||||||
|
|
||||||
class InventoryItemTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCase):
|
class InventoryItemTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTestCase):
|
||||||
model = InventoryItemTemplate
|
model = InventoryItemTemplate
|
||||||
|
validation_excluded_fields = ('name', 'label')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
@ -1454,7 +1464,7 @@ class InventoryItemTemplateTestCase(ViewTestCases.DeviceComponentTemplateViewTes
|
|||||||
|
|
||||||
cls.bulk_create_data = {
|
cls.bulk_create_data = {
|
||||||
'device_type': devicetypes[1].pk,
|
'device_type': devicetypes[1].pk,
|
||||||
'name_pattern': 'Inventory Item Template [4-6]',
|
'name': 'Inventory Item Template [4-6]',
|
||||||
'manufacturer': manufacturers[1].pk,
|
'manufacturer': manufacturers[1].pk,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1912,6 +1922,7 @@ class ModuleTestCase(
|
|||||||
|
|
||||||
class ConsolePortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
class ConsolePortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
||||||
model = ConsolePort
|
model = ConsolePort
|
||||||
|
validation_excluded_fields = ('name', 'label')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
@ -1935,9 +1946,9 @@ class ConsolePortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
|
|
||||||
cls.bulk_create_data = {
|
cls.bulk_create_data = {
|
||||||
'device': device.pk,
|
'device': device.pk,
|
||||||
'name_pattern': 'Console Port [4-6]',
|
'name': 'Console Port [4-6]',
|
||||||
# Test that a label can be applied to each generated console ports
|
# Test that a label can be applied to each generated console ports
|
||||||
'label_pattern': 'Serial[3-5]',
|
'label': 'Serial[3-5]',
|
||||||
'type': ConsolePortTypeChoices.TYPE_RJ45,
|
'type': ConsolePortTypeChoices.TYPE_RJ45,
|
||||||
'description': 'A console port',
|
'description': 'A console port',
|
||||||
'tags': sorted([t.pk for t in tags]),
|
'tags': sorted([t.pk for t in tags]),
|
||||||
@ -1970,6 +1981,7 @@ class ConsolePortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
|
|
||||||
class ConsoleServerPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
class ConsoleServerPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
||||||
model = ConsoleServerPort
|
model = ConsoleServerPort
|
||||||
|
validation_excluded_fields = ('name', 'label')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
@ -1993,7 +2005,7 @@ class ConsoleServerPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
|
|
||||||
cls.bulk_create_data = {
|
cls.bulk_create_data = {
|
||||||
'device': device.pk,
|
'device': device.pk,
|
||||||
'name_pattern': 'Console Server Port [4-6]',
|
'name': 'Console Server Port [4-6]',
|
||||||
'type': ConsolePortTypeChoices.TYPE_RJ45,
|
'type': ConsolePortTypeChoices.TYPE_RJ45,
|
||||||
'description': 'A console server port',
|
'description': 'A console server port',
|
||||||
'tags': [t.pk for t in tags],
|
'tags': [t.pk for t in tags],
|
||||||
@ -2026,6 +2038,7 @@ class ConsoleServerPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
|
|
||||||
class PowerPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
class PowerPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
||||||
model = PowerPort
|
model = PowerPort
|
||||||
|
validation_excluded_fields = ('name', 'label')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
@ -2051,7 +2064,7 @@ class PowerPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
|
|
||||||
cls.bulk_create_data = {
|
cls.bulk_create_data = {
|
||||||
'device': device.pk,
|
'device': device.pk,
|
||||||
'name_pattern': 'Power Port [4-6]]',
|
'name': 'Power Port [4-6]]',
|
||||||
'type': PowerPortTypeChoices.TYPE_IEC_C14,
|
'type': PowerPortTypeChoices.TYPE_IEC_C14,
|
||||||
'maximum_draw': 100,
|
'maximum_draw': 100,
|
||||||
'allocated_draw': 50,
|
'allocated_draw': 50,
|
||||||
@ -2088,6 +2101,7 @@ class PowerPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
|
|
||||||
class PowerOutletTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
class PowerOutletTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
||||||
model = PowerOutlet
|
model = PowerOutlet
|
||||||
|
validation_excluded_fields = ('name', 'label')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
@ -2119,7 +2133,7 @@ class PowerOutletTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
|
|
||||||
cls.bulk_create_data = {
|
cls.bulk_create_data = {
|
||||||
'device': device.pk,
|
'device': device.pk,
|
||||||
'name_pattern': 'Power Outlet [4-6]',
|
'name': 'Power Outlet [4-6]',
|
||||||
'type': PowerOutletTypeChoices.TYPE_IEC_C13,
|
'type': PowerOutletTypeChoices.TYPE_IEC_C13,
|
||||||
'power_port': powerports[1].pk,
|
'power_port': powerports[1].pk,
|
||||||
'feed_leg': PowerOutletFeedLegChoices.FEED_LEG_B,
|
'feed_leg': PowerOutletFeedLegChoices.FEED_LEG_B,
|
||||||
@ -2153,6 +2167,7 @@ class PowerOutletTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
|
|
||||||
class InterfaceTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
class InterfaceTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
||||||
model = Interface
|
model = Interface
|
||||||
|
validation_excluded_fields = ('name', 'label')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
@ -2217,7 +2232,7 @@ class InterfaceTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
|
|
||||||
cls.bulk_create_data = {
|
cls.bulk_create_data = {
|
||||||
'device': device.pk,
|
'device': device.pk,
|
||||||
'name_pattern': 'Interface [4-6]',
|
'name': 'Interface [4-6]',
|
||||||
'type': InterfaceTypeChoices.TYPE_1GE_GBIC,
|
'type': InterfaceTypeChoices.TYPE_1GE_GBIC,
|
||||||
'enabled': False,
|
'enabled': False,
|
||||||
'bridge': interfaces[4].pk,
|
'bridge': interfaces[4].pk,
|
||||||
@ -2277,6 +2292,7 @@ class InterfaceTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
|
|
||||||
class FrontPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
class FrontPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
||||||
model = FrontPort
|
model = FrontPort
|
||||||
|
validation_excluded_fields = ('name', 'label')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
@ -2312,7 +2328,7 @@ class FrontPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
|
|
||||||
cls.bulk_create_data = {
|
cls.bulk_create_data = {
|
||||||
'device': device.pk,
|
'device': device.pk,
|
||||||
'name_pattern': 'Front Port [4-6]',
|
'name': 'Front Port [4-6]',
|
||||||
'type': PortTypeChoices.TYPE_8P8C,
|
'type': PortTypeChoices.TYPE_8P8C,
|
||||||
'rear_port_set': [
|
'rear_port_set': [
|
||||||
'{}:1'.format(rp.pk) for rp in rearports[3:6]
|
'{}:1'.format(rp.pk) for rp in rearports[3:6]
|
||||||
@ -2348,6 +2364,7 @@ class FrontPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
|
|
||||||
class RearPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
class RearPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
||||||
model = RearPort
|
model = RearPort
|
||||||
|
validation_excluded_fields = ('name', 'label')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
@ -2372,7 +2389,7 @@ class RearPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
|
|
||||||
cls.bulk_create_data = {
|
cls.bulk_create_data = {
|
||||||
'device': device.pk,
|
'device': device.pk,
|
||||||
'name_pattern': 'Rear Port [4-6]',
|
'name': 'Rear Port [4-6]',
|
||||||
'type': PortTypeChoices.TYPE_8P8C,
|
'type': PortTypeChoices.TYPE_8P8C,
|
||||||
'positions': 3,
|
'positions': 3,
|
||||||
'description': 'A rear port',
|
'description': 'A rear port',
|
||||||
@ -2406,6 +2423,7 @@ class RearPortTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
|
|
||||||
class ModuleBayTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
class ModuleBayTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
||||||
model = ModuleBay
|
model = ModuleBay
|
||||||
|
validation_excluded_fields = ('name', 'label')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
@ -2428,7 +2446,7 @@ class ModuleBayTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
|
|
||||||
cls.bulk_create_data = {
|
cls.bulk_create_data = {
|
||||||
'device': device.pk,
|
'device': device.pk,
|
||||||
'name_pattern': 'Module Bay [4-6]',
|
'name': 'Module Bay [4-6]',
|
||||||
'description': 'A module bay',
|
'description': 'A module bay',
|
||||||
'tags': [t.pk for t in tags],
|
'tags': [t.pk for t in tags],
|
||||||
}
|
}
|
||||||
@ -2447,6 +2465,7 @@ class ModuleBayTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
|
|
||||||
class DeviceBayTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
class DeviceBayTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
||||||
model = DeviceBay
|
model = DeviceBay
|
||||||
|
validation_excluded_fields = ('name', 'label')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
@ -2472,7 +2491,7 @@ class DeviceBayTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
|
|
||||||
cls.bulk_create_data = {
|
cls.bulk_create_data = {
|
||||||
'device': device.pk,
|
'device': device.pk,
|
||||||
'name_pattern': 'Device Bay [4-6]',
|
'name': 'Device Bay [4-6]',
|
||||||
'description': 'A device bay',
|
'description': 'A device bay',
|
||||||
'tags': [t.pk for t in tags],
|
'tags': [t.pk for t in tags],
|
||||||
}
|
}
|
||||||
@ -2491,6 +2510,7 @@ class DeviceBayTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
|
|
||||||
class InventoryItemTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
class InventoryItemTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
||||||
model = InventoryItem
|
model = InventoryItem
|
||||||
|
validation_excluded_fields = ('name', 'label')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
@ -2525,7 +2545,7 @@ class InventoryItemTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
|||||||
|
|
||||||
cls.bulk_create_data = {
|
cls.bulk_create_data = {
|
||||||
'device': device.pk,
|
'device': device.pk,
|
||||||
'name_pattern': 'Inventory Item [4-6]',
|
'name': 'Inventory Item [4-6]',
|
||||||
'role': roles[1].pk,
|
'role': roles[1].pk,
|
||||||
'manufacturer': manufacturer.pk,
|
'manufacturer': manufacturer.pk,
|
||||||
'parent': None,
|
'parent': None,
|
||||||
|
@ -466,6 +466,7 @@ class ViewTestCases:
|
|||||||
"""
|
"""
|
||||||
bulk_create_count = 3
|
bulk_create_count = 3
|
||||||
bulk_create_data = {}
|
bulk_create_data = {}
|
||||||
|
validation_excluded_fields = []
|
||||||
|
|
||||||
@override_settings(EXEMPT_VIEW_PERMISSIONS=[])
|
@override_settings(EXEMPT_VIEW_PERMISSIONS=[])
|
||||||
def test_create_multiple_objects_without_permission(self):
|
def test_create_multiple_objects_without_permission(self):
|
||||||
@ -500,7 +501,7 @@ class ViewTestCases:
|
|||||||
self.assertHttpStatus(response, 302)
|
self.assertHttpStatus(response, 302)
|
||||||
self.assertEqual(initial_count + self.bulk_create_count, self._get_queryset().count())
|
self.assertEqual(initial_count + self.bulk_create_count, self._get_queryset().count())
|
||||||
for instance in self._get_queryset().order_by('-pk')[:self.bulk_create_count]:
|
for instance in self._get_queryset().order_by('-pk')[:self.bulk_create_count]:
|
||||||
self.assertInstanceEqual(instance, self.bulk_create_data)
|
self.assertInstanceEqual(instance, self.bulk_create_data, exclude=self.validation_excluded_fields)
|
||||||
|
|
||||||
@override_settings(EXEMPT_VIEW_PERMISSIONS=[])
|
@override_settings(EXEMPT_VIEW_PERMISSIONS=[])
|
||||||
def test_create_multiple_objects_with_constrained_permission(self):
|
def test_create_multiple_objects_with_constrained_permission(self):
|
||||||
@ -532,7 +533,7 @@ class ViewTestCases:
|
|||||||
self.assertHttpStatus(response, 302)
|
self.assertHttpStatus(response, 302)
|
||||||
self.assertEqual(initial_count + self.bulk_create_count, self._get_queryset().count())
|
self.assertEqual(initial_count + self.bulk_create_count, self._get_queryset().count())
|
||||||
for instance in self._get_queryset().order_by('-pk')[:self.bulk_create_count]:
|
for instance in self._get_queryset().order_by('-pk')[:self.bulk_create_count]:
|
||||||
self.assertInstanceEqual(instance, self.bulk_create_data)
|
self.assertInstanceEqual(instance, self.bulk_create_data, exclude=self.validation_excluded_fields)
|
||||||
|
|
||||||
class BulkImportObjectsViewTestCase(ModelViewTestCase):
|
class BulkImportObjectsViewTestCase(ModelViewTestCase):
|
||||||
"""
|
"""
|
||||||
|
@ -251,6 +251,7 @@ class VirtualMachineTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
|
|
||||||
class VMInterfaceTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
class VMInterfaceTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
||||||
model = VMInterface
|
model = VMInterface
|
||||||
|
validation_excluded_fields = ('name', 'label')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
|
Loading…
Reference in New Issue
Block a user