mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-08 16:48:16 -06:00
12826 fix tests
This commit is contained in:
parent
d6815ff033
commit
d6721dfdb2
@ -43,12 +43,12 @@ class RackTypeSerializer(NetBoxModelSerializer):
|
||||
class Meta:
|
||||
model = RackType
|
||||
fields = [
|
||||
'id', 'url', 'display_url', 'display', 'name',
|
||||
'id', 'url', 'display_url', 'display', 'name', 'slug',
|
||||
'type', 'width', 'u_height', 'starting_unit', 'weight', 'max_weight',
|
||||
'weight_unit', 'desc_units', 'outer_width', 'outer_depth', 'outer_unit', 'mounting_depth', 'description',
|
||||
'comments', 'tags', 'custom_fields', 'created', 'last_updated',
|
||||
]
|
||||
brief_fields = ('id', 'url', 'display', 'name', 'description')
|
||||
brief_fields = ('id', 'url', 'display', 'name', 'slug', 'description')
|
||||
|
||||
|
||||
class RackSerializer(NetBoxModelSerializer):
|
||||
|
@ -301,7 +301,7 @@ class RackTypeFilterSet(NetBoxModelFilterSet):
|
||||
class Meta:
|
||||
model = RackType
|
||||
fields = (
|
||||
'id', 'name', 'u_height', 'starting_unit', 'desc_units', 'outer_width',
|
||||
'id', 'name', 'slug', 'u_height', 'starting_unit', 'desc_units', 'outer_width',
|
||||
'outer_depth', 'outer_unit', 'mounting_depth', 'weight', 'max_weight', 'weight_unit', 'description',
|
||||
)
|
||||
|
||||
|
@ -612,7 +612,7 @@ class PowerPortTemplateType(ModularComponentTemplateType):
|
||||
fields='__all__',
|
||||
filters=RackTypeFilter
|
||||
)
|
||||
class RackTypeType(ImageAttachmentsMixin, NetBoxObjectType):
|
||||
class RackTypeType(NetBoxObjectType):
|
||||
_name: str
|
||||
|
||||
|
||||
|
@ -276,7 +276,7 @@ class RackRoleTest(APIViewTestCases.APIViewTestCase):
|
||||
|
||||
class RackTypeTest(APIViewTestCases.APIViewTestCase):
|
||||
model = RackType
|
||||
brief_fields = ['description', 'display', 'id', 'name', 'url']
|
||||
brief_fields = ['description', 'display', 'id', 'name', 'slug', 'url']
|
||||
bulk_update_data = {
|
||||
'description': 'new description',
|
||||
}
|
||||
@ -285,21 +285,24 @@ class RackTypeTest(APIViewTestCases.APIViewTestCase):
|
||||
def setUpTestData(cls):
|
||||
|
||||
racks = (
|
||||
RackType(name='Rack 1'),
|
||||
RackType(name='Rack 2'),
|
||||
RackType(name='Rack 3'),
|
||||
RackType(name='RackType 1', slug='rack-type-1'),
|
||||
RackType(name='RackType 2', slug='rack-type-2'),
|
||||
RackType(name='RackType 3', slug='rack-type-3'),
|
||||
)
|
||||
RackType.objects.bulk_create(racks)
|
||||
|
||||
cls.create_data = [
|
||||
{
|
||||
'name': 'Test Rack 4',
|
||||
'name': 'Test RackType 4',
|
||||
'slug': 'test-rack-type-4',
|
||||
},
|
||||
{
|
||||
'name': 'Test Rack 5',
|
||||
'name': 'Test RackType 5',
|
||||
'slug': 'test-rack-type-5',
|
||||
},
|
||||
{
|
||||
'name': 'Test Rack 6',
|
||||
'name': 'Test RackType 6',
|
||||
'slug': 'test-rack-type-6',
|
||||
},
|
||||
]
|
||||
|
||||
|
@ -477,7 +477,8 @@ class RackTypeTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
|
||||
racks = (
|
||||
RackType(
|
||||
name='Rack 1',
|
||||
name='RackType 1',
|
||||
slug='rack-type-1',
|
||||
type=RackTypeChoices.TYPE_2POST,
|
||||
width=RackWidthChoices.WIDTH_19IN,
|
||||
u_height=42,
|
||||
@ -491,7 +492,8 @@ class RackTypeTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
description='foobar1'
|
||||
),
|
||||
RackType(
|
||||
name='Rack 2',
|
||||
name='RackType 2',
|
||||
slug='rack-type-2',
|
||||
type=RackTypeChoices.TYPE_4POST,
|
||||
width=RackWidthChoices.WIDTH_21IN,
|
||||
u_height=43,
|
||||
@ -505,7 +507,8 @@ class RackTypeTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
description='foobar2'
|
||||
),
|
||||
RackType(
|
||||
name='Rack 3',
|
||||
name='RackType 3',
|
||||
slug='rack-type-3',
|
||||
type=RackTypeChoices.TYPE_CABINET,
|
||||
width=RackWidthChoices.WIDTH_23IN,
|
||||
u_height=44,
|
||||
@ -526,7 +529,11 @@ class RackTypeTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
|
||||
|
||||
def test_name(self):
|
||||
params = {'name': ['Rack 1', 'Rack 2']}
|
||||
params = {'name': ['RackType 1', 'RackType 2']}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
def test_slug(self):
|
||||
params = {'slug': ['rack-type-1', 'rack-type-2']}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
def test_description(self):
|
||||
|
Loading…
Reference in New Issue
Block a user