mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-16 12:12:53 -06:00
* Shorten choice constant names * Add filter tests for airflow
This commit is contained in:
parent
db6246a437
commit
00d8eb40fc
@ -129,12 +129,12 @@ class RackElevationDetailRenderChoices(ChoiceSet):
|
|||||||
|
|
||||||
class RackAirflowChoices(ChoiceSet):
|
class RackAirflowChoices(ChoiceSet):
|
||||||
|
|
||||||
AIRFLOW_FRONT_TO_REAR = 'front-to-rear'
|
FRONT_TO_REAR = 'front-to-rear'
|
||||||
AIRFLOW_REAR_TO_FRONT = 'rear-to-front'
|
REAR_TO_FRONT = 'rear-to-front'
|
||||||
|
|
||||||
CHOICES = (
|
CHOICES = (
|
||||||
(AIRFLOW_FRONT_TO_REAR, _('Front to rear')),
|
(FRONT_TO_REAR, _('Front to rear')),
|
||||||
(AIRFLOW_REAR_TO_FRONT, _('Rear to front')),
|
(REAR_TO_FRONT, _('Rear to front')),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -237,20 +237,20 @@ class ModuleStatusChoices(ChoiceSet):
|
|||||||
|
|
||||||
class ModuleAirflowChoices(ChoiceSet):
|
class ModuleAirflowChoices(ChoiceSet):
|
||||||
|
|
||||||
AIRFLOW_FRONT_TO_REAR = 'front-to-rear'
|
FRONT_TO_REAR = 'front-to-rear'
|
||||||
AIRFLOW_REAR_TO_FRONT = 'rear-to-front'
|
REAR_TO_FRONT = 'rear-to-front'
|
||||||
AIRFLOW_LEFT_TO_RIGHT = 'left-to-right'
|
LEFT_TO_RIGHT = 'left-to-right'
|
||||||
AIRFLOW_RIGHT_TO_LEFT = 'right-to-left'
|
RIGHT_TO_LEFT = 'right-to-left'
|
||||||
AIRFLOW_SIDE_TO_REAR = 'side-to-rear'
|
SIDE_TO_REAR = 'side-to-rear'
|
||||||
AIRFLOW_PASSIVE = 'passive'
|
PASSIVE = 'passive'
|
||||||
|
|
||||||
CHOICES = (
|
CHOICES = (
|
||||||
(AIRFLOW_FRONT_TO_REAR, _('Front to rear')),
|
(FRONT_TO_REAR, _('Front to rear')),
|
||||||
(AIRFLOW_REAR_TO_FRONT, _('Rear to front')),
|
(REAR_TO_FRONT, _('Rear to front')),
|
||||||
(AIRFLOW_LEFT_TO_RIGHT, _('Left to right')),
|
(LEFT_TO_RIGHT, _('Left to right')),
|
||||||
(AIRFLOW_RIGHT_TO_LEFT, _('Right to left')),
|
(RIGHT_TO_LEFT, _('Right to left')),
|
||||||
(AIRFLOW_SIDE_TO_REAR, _('Side to rear')),
|
(SIDE_TO_REAR, _('Side to rear')),
|
||||||
(AIRFLOW_PASSIVE, _('Passive')),
|
(PASSIVE, _('Passive')),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -500,7 +500,8 @@ class RackTypeTestCase(TestCase, ChangeLoggedFilterSetTests):
|
|||||||
weight=10,
|
weight=10,
|
||||||
max_weight=1000,
|
max_weight=1000,
|
||||||
weight_unit=WeightUnitChoices.UNIT_POUND,
|
weight_unit=WeightUnitChoices.UNIT_POUND,
|
||||||
description='foobar1'
|
description='foobar1',
|
||||||
|
airflow=RackAirflowChoices.FRONT_TO_REAR
|
||||||
),
|
),
|
||||||
RackType(
|
RackType(
|
||||||
manufacturer=manufacturers[1],
|
manufacturer=manufacturers[1],
|
||||||
@ -518,7 +519,8 @@ class RackTypeTestCase(TestCase, ChangeLoggedFilterSetTests):
|
|||||||
weight=20,
|
weight=20,
|
||||||
max_weight=2000,
|
max_weight=2000,
|
||||||
weight_unit=WeightUnitChoices.UNIT_POUND,
|
weight_unit=WeightUnitChoices.UNIT_POUND,
|
||||||
description='foobar2'
|
description='foobar2',
|
||||||
|
airflow=RackAirflowChoices.REAR_TO_FRONT
|
||||||
),
|
),
|
||||||
RackType(
|
RackType(
|
||||||
manufacturer=manufacturers[2],
|
manufacturer=manufacturers[2],
|
||||||
@ -615,6 +617,10 @@ class RackTypeTestCase(TestCase, ChangeLoggedFilterSetTests):
|
|||||||
params = {'weight_unit': WeightUnitChoices.UNIT_POUND}
|
params = {'weight_unit': WeightUnitChoices.UNIT_POUND}
|
||||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||||
|
|
||||||
|
def test_airflow(self):
|
||||||
|
params = {'airflow': RackAirflowChoices.REAR_TO_FRONT}
|
||||||
|
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
|
||||||
|
|
||||||
|
|
||||||
class RackTestCase(TestCase, ChangeLoggedFilterSetTests):
|
class RackTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||||
queryset = Rack.objects.all()
|
queryset = Rack.objects.all()
|
||||||
@ -745,7 +751,8 @@ class RackTestCase(TestCase, ChangeLoggedFilterSetTests):
|
|||||||
weight=10,
|
weight=10,
|
||||||
max_weight=1000,
|
max_weight=1000,
|
||||||
weight_unit=WeightUnitChoices.UNIT_POUND,
|
weight_unit=WeightUnitChoices.UNIT_POUND,
|
||||||
description='foobar1'
|
description='foobar1',
|
||||||
|
airflow=RackAirflowChoices.FRONT_TO_REAR
|
||||||
),
|
),
|
||||||
Rack(
|
Rack(
|
||||||
name='Rack 2',
|
name='Rack 2',
|
||||||
@ -767,7 +774,8 @@ class RackTestCase(TestCase, ChangeLoggedFilterSetTests):
|
|||||||
weight=20,
|
weight=20,
|
||||||
max_weight=2000,
|
max_weight=2000,
|
||||||
weight_unit=WeightUnitChoices.UNIT_POUND,
|
weight_unit=WeightUnitChoices.UNIT_POUND,
|
||||||
description='foobar2'
|
description='foobar2',
|
||||||
|
airflow=RackAirflowChoices.REAR_TO_FRONT
|
||||||
),
|
),
|
||||||
Rack(
|
Rack(
|
||||||
name='Rack 3',
|
name='Rack 3',
|
||||||
@ -958,6 +966,10 @@ class RackTestCase(TestCase, ChangeLoggedFilterSetTests):
|
|||||||
params = {'rack_type': [rack_types[0].slug, rack_types[1].slug]}
|
params = {'rack_type': [rack_types[0].slug, rack_types[1].slug]}
|
||||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||||
|
|
||||||
|
def test_airflow(self):
|
||||||
|
params = {'airflow': RackAirflowChoices.FRONT_TO_REAR}
|
||||||
|
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
|
||||||
|
|
||||||
|
|
||||||
class RackReservationTestCase(TestCase, ChangeLoggedFilterSetTests):
|
class RackReservationTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||||
queryset = RackReservation.objects.all()
|
queryset = RackReservation.objects.all()
|
||||||
@ -1380,7 +1392,8 @@ class ModuleTypeTestCase(TestCase, ChangeLoggedFilterSetTests):
|
|||||||
part_number='Part Number 1',
|
part_number='Part Number 1',
|
||||||
weight=10,
|
weight=10,
|
||||||
weight_unit=WeightUnitChoices.UNIT_POUND,
|
weight_unit=WeightUnitChoices.UNIT_POUND,
|
||||||
description='foobar1'
|
description='foobar1',
|
||||||
|
airflow=ModuleAirflowChoices.FRONT_TO_REAR
|
||||||
),
|
),
|
||||||
ModuleType(
|
ModuleType(
|
||||||
manufacturer=manufacturers[1],
|
manufacturer=manufacturers[1],
|
||||||
@ -1388,7 +1401,8 @@ class ModuleTypeTestCase(TestCase, ChangeLoggedFilterSetTests):
|
|||||||
part_number='Part Number 2',
|
part_number='Part Number 2',
|
||||||
weight=20,
|
weight=20,
|
||||||
weight_unit=WeightUnitChoices.UNIT_POUND,
|
weight_unit=WeightUnitChoices.UNIT_POUND,
|
||||||
description='foobar2'
|
description='foobar2',
|
||||||
|
airflow=ModuleAirflowChoices.REAR_TO_FRONT
|
||||||
),
|
),
|
||||||
ModuleType(
|
ModuleType(
|
||||||
manufacturer=manufacturers[2],
|
manufacturer=manufacturers[2],
|
||||||
@ -1499,6 +1513,10 @@ class ModuleTypeTestCase(TestCase, ChangeLoggedFilterSetTests):
|
|||||||
params = {'weight_unit': WeightUnitChoices.UNIT_POUND}
|
params = {'weight_unit': WeightUnitChoices.UNIT_POUND}
|
||||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||||
|
|
||||||
|
def test_airflow(self):
|
||||||
|
params = {'airflow': RackAirflowChoices.FRONT_TO_REAR}
|
||||||
|
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
|
||||||
|
|
||||||
|
|
||||||
class ConsolePortTemplateTestCase(TestCase, DeviceComponentTemplateFilterSetTests, ChangeLoggedFilterSetTests):
|
class ConsolePortTemplateTestCase(TestCase, DeviceComponentTemplateFilterSetTests, ChangeLoggedFilterSetTests):
|
||||||
queryset = ConsolePortTemplate.objects.all()
|
queryset = ConsolePortTemplate.objects.all()
|
||||||
|
Loading…
Reference in New Issue
Block a user