18981 fix tests

This commit is contained in:
Arthur 2025-03-26 08:36:05 -07:00
parent 86458d28e3
commit ba23d94b58
3 changed files with 20 additions and 18 deletions

View File

@ -12,12 +12,6 @@ class Migration(migrations.Migration):
]
operations = [
migrations.AlterModelManagers(
name='devicerole',
managers=[
('_tree_manager', django.db.models.manager.Manager()),
],
),
migrations.AddField(
model_name='devicerole',
name='level',
@ -53,4 +47,19 @@ class Migration(migrations.Migration):
to='dcim.devicerole',
),
),
migrations.AddField(
model_name='devicerole',
name='comments',
field=models.TextField(blank=True),
),
migrations.AlterField(
model_name='devicerole',
name='name',
field=models.CharField(max_length=100),
),
migrations.AlterField(
model_name='devicerole',
name='slug',
field=models.SlugField(max_length=100),
),
]

View File

@ -21,10 +21,9 @@ from dcim.constants import *
from dcim.fields import MACAddressField
from extras.models import ConfigContextModel, CustomField
from extras.querysets import ConfigContextModelQuerySet
from mptt.models import MPTTModel, TreeForeignKey
from netbox.choices import ColorChoices
from netbox.config import ConfigItem
from netbox.models import OrganizationalModel, PrimaryModel
from netbox.models import NestedGroupModel, OrganizationalModel, PrimaryModel
from netbox.models.mixins import WeightMixin
from netbox.models.features import ContactsMixin, ImageAttachmentsMixin
from utilities.fields import ColorField, CounterCacheField
@ -469,20 +468,12 @@ class ModuleType(ImageAttachmentsMixin, PrimaryModel, WeightMixin):
# Devices
#
class DeviceRole(OrganizationalModel, MPTTModel):
class DeviceRole(NestedGroupModel):
"""
Devices are organized by functional role; for example, "Core Switch" or "File Server". Each DeviceRole is assigned a
color to be used when displaying rack elevations. The vm_role field determines whether the role is applicable to
virtual machines as well.
"""
parent = TreeForeignKey(
to='self',
on_delete=models.CASCADE,
related_name='children',
blank=True,
null=True,
db_index=True
)
color = ColorField(
verbose_name=_('color'),
default=ColorChoices.COLOR_GREY

View File

@ -1149,7 +1149,9 @@ class InventoryItemTemplateTest(APIViewTestCases.APIViewTestCase):
class DeviceRoleTest(APIViewTestCases.APIViewTestCase):
model = DeviceRole
brief_fields = ['description', 'device_count', 'display', 'id', 'name', 'slug', 'url', 'virtualmachine_count']
brief_fields = [
'_depth', 'description', 'device_count', 'display', 'id', 'name', 'slug', 'url', 'virtualmachine_count'
]
create_data = [
{
'name': 'Device Role 4',