17058 RackType name -> model (#17059)

* 17058 RackType name -> model

* 17058 RackType name -> model

* 17058 fix tests

* 17058 fix tests
This commit is contained in:
Arthur Hanson
2024-08-01 20:06:51 +07:00
committed by GitHub
parent c51e91dddd
commit d6f2fc7d29
15 changed files with 74 additions and 59 deletions

View File

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

View File

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

View File

@@ -82,7 +82,7 @@ class RackTypeTestCase(TestCase):
RackType.objects.create(
manufacturer=manufacturer,
name='RackType 1',
model='RackType 1',
slug='rack-type-1',
width=11,
u_height=22,

View File

@@ -346,9 +346,9 @@ class RackTypeTestCase(ViewTestCases.PrimaryObjectViewTestCase):
Manufacturer.objects.bulk_create(manufacturers)
rack_types = (
RackType(manufacturer=manufacturers[0], name='RackType 1', slug='rack-type-1',),
RackType(manufacturer=manufacturers[0], name='RackType 2', slug='rack-type-2',),
RackType(manufacturer=manufacturers[0], name='RackType 3', slug='rack-type-3',),
RackType(manufacturer=manufacturers[0], model='RackType 1', slug='rack-type-1',),
RackType(manufacturer=manufacturers[0], model='RackType 2', slug='rack-type-2',),
RackType(manufacturer=manufacturers[0], model='RackType 3', slug='rack-type-3',),
)
RackType.objects.bulk_create(rack_types)
@@ -356,7 +356,7 @@ class RackTypeTestCase(ViewTestCases.PrimaryObjectViewTestCase):
cls.form_data = {
'manufacturer': manufacturers[1].pk,
'name': 'RackType X',
'model': 'RackType X',
'slug': 'rack-type-x',
'type': RackFormFactorChoices.TYPE_CABINET,
'width': RackWidthChoices.WIDTH_19IN,
@@ -374,14 +374,14 @@ class RackTypeTestCase(ViewTestCases.PrimaryObjectViewTestCase):
}
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 5,rack-type-5,19,42,100,2000,kg",
"Manufacturer 1,RackType 6,rack-type-6,19,42,100,2000,kg",
)
cls.csv_update_data = (
"id,name",
"id,model",
f"{rack_types[0].pk},RackType 7",
f"{rack_types[1].pk},RackType 8",
f"{rack_types[2].pk},RackType 9",