|
@@ -10,7 +10,14 @@ from dcim.filtersets import *
|
|
|
from dcim.models import *
|
|
from dcim.models import *
|
|
|
from ipam.choices import VLANQinQRoleChoices
|
|
from ipam.choices import VLANQinQRoleChoices
|
|
|
from ipam.models import ASN, RIR, VLAN, VRF, IPAddress, VLANTranslationPolicy
|
|
from ipam.models import ASN, RIR, VLAN, VRF, IPAddress, VLANTranslationPolicy
|
|
|
-from netbox.choices import ColorChoices, DiameterUnitChoices, TemperatureUnitChoices, WeightUnitChoices
|
|
|
|
|
|
|
+from netbox.choices import (
|
|
|
|
|
+ ColorChoices,
|
|
|
|
|
+ DiameterUnitChoices,
|
|
|
|
|
+ FlowRateUnitChoices,
|
|
|
|
|
+ PressureUnitChoices,
|
|
|
|
|
+ TemperatureUnitChoices,
|
|
|
|
|
+ WeightUnitChoices,
|
|
|
|
|
+)
|
|
|
from tenancy.models import Tenant, TenantGroup
|
|
from tenancy.models import Tenant, TenantGroup
|
|
|
from users.models import User
|
|
from users.models import User
|
|
|
from utilities.testing import ChangeLoggedFilterSetTests, create_test_device, create_test_virtualmachine
|
|
from utilities.testing import ChangeLoggedFilterSetTests, create_test_device, create_test_virtualmachine
|
|
@@ -8408,7 +8415,9 @@ class CoolingFeedTestCase(TestCase, ChangeLoggedFilterSetTests):
|
|
|
fluid_type=FluidTypeChoices.FLUID_WATER,
|
|
fluid_type=FluidTypeChoices.FLUID_WATER,
|
|
|
cooling_capacity=100,
|
|
cooling_capacity=100,
|
|
|
flow_rate=10,
|
|
flow_rate=10,
|
|
|
|
|
+ flow_rate_unit=FlowRateUnitChoices.UNIT_LITERS_PER_MINUTE,
|
|
|
pressure=100,
|
|
pressure=100,
|
|
|
|
|
+ pressure_unit=PressureUnitChoices.UNIT_KILOPASCAL,
|
|
|
description='foobar1'
|
|
description='foobar1'
|
|
|
),
|
|
),
|
|
|
CoolingFeed(
|
|
CoolingFeed(
|
|
@@ -8421,7 +8430,9 @@ class CoolingFeedTestCase(TestCase, ChangeLoggedFilterSetTests):
|
|
|
fluid_type=FluidTypeChoices.FLUID_WATER,
|
|
fluid_type=FluidTypeChoices.FLUID_WATER,
|
|
|
cooling_capacity=200,
|
|
cooling_capacity=200,
|
|
|
flow_rate=20,
|
|
flow_rate=20,
|
|
|
|
|
+ flow_rate_unit=FlowRateUnitChoices.UNIT_LITERS_PER_MINUTE,
|
|
|
pressure=200,
|
|
pressure=200,
|
|
|
|
|
+ pressure_unit=PressureUnitChoices.UNIT_KILOPASCAL,
|
|
|
description='foobar2'
|
|
description='foobar2'
|
|
|
),
|
|
),
|
|
|
CoolingFeed(
|
|
CoolingFeed(
|
|
@@ -8434,11 +8445,15 @@ class CoolingFeedTestCase(TestCase, ChangeLoggedFilterSetTests):
|
|
|
fluid_type=FluidTypeChoices.FLUID_DIELECTRIC,
|
|
fluid_type=FluidTypeChoices.FLUID_DIELECTRIC,
|
|
|
cooling_capacity=300,
|
|
cooling_capacity=300,
|
|
|
flow_rate=30,
|
|
flow_rate=30,
|
|
|
|
|
+ flow_rate_unit=FlowRateUnitChoices.UNIT_GALLONS_PER_MINUTE,
|
|
|
pressure=300,
|
|
pressure=300,
|
|
|
|
|
+ pressure_unit=PressureUnitChoices.UNIT_PSI,
|
|
|
description='foobar3'
|
|
description='foobar3'
|
|
|
),
|
|
),
|
|
|
)
|
|
)
|
|
|
- CoolingFeed.objects.bulk_create(cooling_feeds)
|
|
|
|
|
|
|
+ # Use save() rather than bulk_create() so the normalized _abs_* fields are populated
|
|
|
|
|
+ for cooling_feed in cooling_feeds:
|
|
|
|
|
+ cooling_feed.save()
|
|
|
|
|
|
|
|
manufacturer = Manufacturer.objects.create(name='Manufacturer', slug='manufacturer')
|
|
manufacturer = Manufacturer.objects.create(name='Manufacturer', slug='manufacturer')
|
|
|
device_type = DeviceType.objects.create(manufacturer=manufacturer, model='Model', slug='model')
|
|
device_type = DeviceType.objects.create(manufacturer=manufacturer, model='Model', slug='model')
|
|
@@ -8480,10 +8495,18 @@ class CoolingFeedTestCase(TestCase, ChangeLoggedFilterSetTests):
|
|
|
params = {'flow_rate': [10, 20]}
|
|
params = {'flow_rate': [10, 20]}
|
|
|
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
|
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
|
|
|
|
|
|
|
|
|
+ def test_flow_rate_unit(self):
|
|
|
|
|
+ params = {'flow_rate_unit': [FlowRateUnitChoices.UNIT_LITERS_PER_MINUTE]}
|
|
|
|
|
+ self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
|
|
|
|
+
|
|
|
def test_pressure(self):
|
|
def test_pressure(self):
|
|
|
params = {'pressure': [100, 200]}
|
|
params = {'pressure': [100, 200]}
|
|
|
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
|
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
|
|
|
|
|
|
|
|
|
+ def test_pressure_unit(self):
|
|
|
|
|
+ params = {'pressure_unit': [PressureUnitChoices.UNIT_KILOPASCAL]}
|
|
|
|
|
+ self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
|
|
|
|
+
|
|
|
def test_description(self):
|
|
def test_description(self):
|
|
|
params = {'description': ['foobar1', 'foobar2']}
|
|
params = {'description': ['foobar1', 'foobar2']}
|
|
|
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
|
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|