12826 fix tests

This commit is contained in:
Arthur Hanson 2024-06-26 11:25:35 -07:00
parent d6815ff033
commit d6721dfdb2
5 changed files with 25 additions and 15 deletions

View File

@ -43,12 +43,12 @@ class RackTypeSerializer(NetBoxModelSerializer):
class Meta: class Meta:
model = RackType model = RackType
fields = [ fields = [
'id', 'url', 'display_url', 'display', 'name', 'id', 'url', 'display_url', 'display', 'name', 'slug',
'type', 'width', 'u_height', 'starting_unit', 'weight', 'max_weight', 'type', 'width', 'u_height', 'starting_unit', 'weight', 'max_weight',
'weight_unit', 'desc_units', 'outer_width', 'outer_depth', 'outer_unit', 'mounting_depth', 'description', 'weight_unit', 'desc_units', 'outer_width', 'outer_depth', 'outer_unit', 'mounting_depth', 'description',
'comments', 'tags', 'custom_fields', 'created', 'last_updated', '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): class RackSerializer(NetBoxModelSerializer):

View File

@ -301,7 +301,7 @@ class RackTypeFilterSet(NetBoxModelFilterSet):
class Meta: class Meta:
model = RackType model = RackType
fields = ( 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', 'outer_depth', 'outer_unit', 'mounting_depth', 'weight', 'max_weight', 'weight_unit', 'description',
) )

View File

@ -612,7 +612,7 @@ class PowerPortTemplateType(ModularComponentTemplateType):
fields='__all__', fields='__all__',
filters=RackTypeFilter filters=RackTypeFilter
) )
class RackTypeType(ImageAttachmentsMixin, NetBoxObjectType): class RackTypeType(NetBoxObjectType):
_name: str _name: str

View File

@ -276,7 +276,7 @@ class RackRoleTest(APIViewTestCases.APIViewTestCase):
class RackTypeTest(APIViewTestCases.APIViewTestCase): class RackTypeTest(APIViewTestCases.APIViewTestCase):
model = RackType model = RackType
brief_fields = ['description', 'display', 'id', 'name', 'url'] brief_fields = ['description', 'display', 'id', 'name', 'slug', 'url']
bulk_update_data = { bulk_update_data = {
'description': 'new description', 'description': 'new description',
} }
@ -285,21 +285,24 @@ class RackTypeTest(APIViewTestCases.APIViewTestCase):
def setUpTestData(cls): def setUpTestData(cls):
racks = ( racks = (
RackType(name='Rack 1'), RackType(name='RackType 1', slug='rack-type-1'),
RackType(name='Rack 2'), RackType(name='RackType 2', slug='rack-type-2'),
RackType(name='Rack 3'), RackType(name='RackType 3', slug='rack-type-3'),
) )
RackType.objects.bulk_create(racks) RackType.objects.bulk_create(racks)
cls.create_data = [ 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',
}, },
] ]

View File

@ -477,7 +477,8 @@ class RackTypeTestCase(TestCase, ChangeLoggedFilterSetTests):
racks = ( racks = (
RackType( RackType(
name='Rack 1', name='RackType 1',
slug='rack-type-1',
type=RackTypeChoices.TYPE_2POST, type=RackTypeChoices.TYPE_2POST,
width=RackWidthChoices.WIDTH_19IN, width=RackWidthChoices.WIDTH_19IN,
u_height=42, u_height=42,
@ -491,7 +492,8 @@ class RackTypeTestCase(TestCase, ChangeLoggedFilterSetTests):
description='foobar1' description='foobar1'
), ),
RackType( RackType(
name='Rack 2', name='RackType 2',
slug='rack-type-2',
type=RackTypeChoices.TYPE_4POST, type=RackTypeChoices.TYPE_4POST,
width=RackWidthChoices.WIDTH_21IN, width=RackWidthChoices.WIDTH_21IN,
u_height=43, u_height=43,
@ -505,7 +507,8 @@ class RackTypeTestCase(TestCase, ChangeLoggedFilterSetTests):
description='foobar2' description='foobar2'
), ),
RackType( RackType(
name='Rack 3', name='RackType 3',
slug='rack-type-3',
type=RackTypeChoices.TYPE_CABINET, type=RackTypeChoices.TYPE_CABINET,
width=RackWidthChoices.WIDTH_23IN, width=RackWidthChoices.WIDTH_23IN,
u_height=44, u_height=44,
@ -526,7 +529,11 @@ class RackTypeTestCase(TestCase, ChangeLoggedFilterSetTests):
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
def test_name(self): 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) self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
def test_description(self): def test_description(self):