17058 fix tests

This commit is contained in:
Arthur Hanson 2024-08-01 14:58:27 +07:00
parent bcb99cdacd
commit 6b9d1ddb93
3 changed files with 18 additions and 18 deletions

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', 'manufacturer', 'name', 'slug', 'url'] brief_fields = ['description', 'display', 'id', 'manufacturer', 'model', 'slug', 'url']
bulk_update_data = { bulk_update_data = {
'description': 'new description', 'description': 'new description',
} }
@ -290,26 +290,26 @@ class RackTypeTest(APIViewTestCases.APIViewTestCase):
Manufacturer.objects.bulk_create(manufacturers) Manufacturer.objects.bulk_create(manufacturers)
rack_types = ( rack_types = (
RackType(manufacturer=manufacturers[0], name='Rack Type 1', slug='rack-type-1'), RackType(manufacturer=manufacturers[0], model='Rack Type 1', slug='rack-type-1'),
RackType(manufacturer=manufacturers[0], name='Rack Type 2', slug='rack-type-2'), RackType(manufacturer=manufacturers[0], model='Rack Type 2', slug='rack-type-2'),
RackType(manufacturer=manufacturers[0], name='Rack Type 3', slug='rack-type-3'), RackType(manufacturer=manufacturers[0], model='Rack Type 3', slug='rack-type-3'),
) )
RackType.objects.bulk_create(rack_types) RackType.objects.bulk_create(rack_types)
cls.create_data = [ cls.create_data = [
{ {
'manufacturer': manufacturers[1].pk, 'manufacturer': manufacturers[1].pk,
'name': 'Rack Type 4', 'model': 'Rack Type 4',
'slug': 'rack-type-4', 'slug': 'rack-type-4',
}, },
{ {
'manufacturer': manufacturers[1].pk, 'manufacturer': manufacturers[1].pk,
'name': 'Rack Type 5', 'model': 'Rack Type 5',
'slug': 'rack-type-5', 'slug': 'rack-type-5',
}, },
{ {
'manufacturer': manufacturers[1].pk, 'manufacturer': manufacturers[1].pk,
'name': 'Rack Type 6', 'model': 'Rack Type 6',
'slug': 'rack-type-6', 'slug': 'rack-type-6',
}, },
] ]

View File

@ -484,7 +484,7 @@ class RackTypeTestCase(TestCase, ChangeLoggedFilterSetTests):
racks = ( racks = (
RackType( RackType(
manufacturer=manufacturers[0], manufacturer=manufacturers[0],
name='RackType 1', model='RackType 1',
slug='rack-type-1', slug='rack-type-1',
form_factor=RackFormFactorChoices.TYPE_2POST, form_factor=RackFormFactorChoices.TYPE_2POST,
width=RackWidthChoices.WIDTH_19IN, width=RackWidthChoices.WIDTH_19IN,
@ -502,7 +502,7 @@ class RackTypeTestCase(TestCase, ChangeLoggedFilterSetTests):
), ),
RackType( RackType(
manufacturer=manufacturers[1], manufacturer=manufacturers[1],
name='RackType 2', model='RackType 2',
slug='rack-type-2', slug='rack-type-2',
form_factor=RackFormFactorChoices.TYPE_4POST, form_factor=RackFormFactorChoices.TYPE_4POST,
width=RackWidthChoices.WIDTH_21IN, width=RackWidthChoices.WIDTH_21IN,
@ -520,7 +520,7 @@ class RackTypeTestCase(TestCase, ChangeLoggedFilterSetTests):
), ),
RackType( RackType(
manufacturer=manufacturers[2], manufacturer=manufacturers[2],
name='RackType 3', model='RackType 3',
slug='rack-type-3', slug='rack-type-3',
form_factor=RackFormFactorChoices.TYPE_CABINET, form_factor=RackFormFactorChoices.TYPE_CABINET,
width=RackWidthChoices.WIDTH_23IN, width=RackWidthChoices.WIDTH_23IN,
@ -550,8 +550,8 @@ class RackTypeTestCase(TestCase, ChangeLoggedFilterSetTests):
params = {'manufacturer': [manufacturers[0].slug, manufacturers[1].slug]} params = {'manufacturer': [manufacturers[0].slug, manufacturers[1].slug]}
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
def test_name(self): def test_model(self):
params = {'name': ['RackType 1', 'RackType 2']} params = {'model': ['RackType 1', 'RackType 2']}
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
def test_slug(self): def test_slug(self):

View File

@ -348,9 +348,9 @@ class RackTypeTestCase(ViewTestCases.PrimaryObjectViewTestCase):
Manufacturer.objects.bulk_create(manufacturers) Manufacturer.objects.bulk_create(manufacturers)
rack_types = ( rack_types = (
RackType(manufacturer=manufacturers[0], name='RackType 1', slug='rack-type-1',), RackType(manufacturer=manufacturers[0], model='RackType 1', slug='rack-type-1',),
RackType(manufacturer=manufacturers[0], name='RackType 2', slug='rack-type-2',), RackType(manufacturer=manufacturers[0], model='RackType 2', slug='rack-type-2',),
RackType(manufacturer=manufacturers[0], name='RackType 3', slug='rack-type-3',), RackType(manufacturer=manufacturers[0], model='RackType 3', slug='rack-type-3',),
) )
RackType.objects.bulk_create(rack_types) RackType.objects.bulk_create(rack_types)
@ -358,7 +358,7 @@ class RackTypeTestCase(ViewTestCases.PrimaryObjectViewTestCase):
cls.form_data = { cls.form_data = {
'manufacturer': manufacturers[1].pk, 'manufacturer': manufacturers[1].pk,
'name': 'RackType X', 'model': 'RackType X',
'slug': 'rack-type-x', 'slug': 'rack-type-x',
'type': RackFormFactorChoices.TYPE_CABINET, 'type': RackFormFactorChoices.TYPE_CABINET,
'width': RackWidthChoices.WIDTH_19IN, 'width': RackWidthChoices.WIDTH_19IN,
@ -376,14 +376,14 @@ class RackTypeTestCase(ViewTestCases.PrimaryObjectViewTestCase):
} }
cls.csv_data = ( cls.csv_data = (
"manufacturer,name,slug,width,u_height,weight,max_weight,weight_unit", "manufacturer,model,slug,width,u_height,weight,max_weight,weight_unit",
"Manufacturer 1,RackType 4,rack-type-4,19,42,100,2000,kg", "Manufacturer 1,RackType 4,rack-type-4,19,42,100,2000,kg",
"Manufacturer 1,RackType 5,rack-type-5,19,42,100,2000,kg", "Manufacturer 1,RackType 5,rack-type-5,19,42,100,2000,kg",
"Manufacturer 1,RackType 6,rack-type-6,19,42,100,2000,kg", "Manufacturer 1,RackType 6,rack-type-6,19,42,100,2000,kg",
) )
cls.csv_update_data = ( cls.csv_update_data = (
"id,name", "id,model",
f"{rack_types[0].pk},RackType 7", f"{rack_types[0].pk},RackType 7",
f"{rack_types[1].pk},RackType 8", f"{rack_types[1].pk},RackType 8",
f"{rack_types[2].pk},RackType 9", f"{rack_types[2].pk},RackType 9",