Browse Source

Add test for validation of device within rack height.

Ryan Breaker 7 years ago
parent
commit
937faaf149
1 changed files with 25 additions and 0 deletions
  1. 25 0
      netbox/dcim/tests/test_models.py

+ 25 - 0
netbox/dcim/tests/test_models.py

@@ -72,7 +72,32 @@ class RackTestCase(TestCase):
 
         }
 
+    def test_rack_device_outside_height(self):
+
+        rack1 = Rack(
+            name='TestRack2',
+            facility_id='A102',
+            site=self.site1,
+            u_height=42
+        )
+        rack1.save()
+
+        device1 = Device(
+            name='TestSwitch1',
+            device_type=DeviceType.objects.get(manufacturer__slug='acme', slug='ff2048'),
+            device_role=DeviceRole.objects.get(slug='switch'),
+            site=self.site1,
+            rack=rack1,
+            position=43,
+            face=RACK_FACE_FRONT,
+        )
+        device1.save()
+
+        with self.assertRaises(ValidationError):
+            rack1.clean()
+
     def test_rack_group_site(self):
+
         rack_invalid_group = Rack(
             name='TestRack2',
             facility_id='A102',