Skip to content

Commit b5f9fe6

Browse files
arthansonjeremystretch
authored andcommitted
7503 add test
1 parent fc9555a commit b5f9fe6

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

netbox/dcim/tests/test_api.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@ def setUpTestData(cls):
11151115

11161116
device_types = (
11171117
DeviceType(manufacturer=manufacturer, model='Device Type 1', slug='device-type-1'),
1118-
DeviceType(manufacturer=manufacturer, model='Device Type 2', slug='device-type-2'),
1118+
DeviceType(manufacturer=manufacturer, model='Device Type 2', slug='device-type-2', u_height=2),
11191119
)
11201120
DeviceType.objects.bulk_create(device_types)
11211121

@@ -1229,6 +1229,39 @@ def test_unique_name_per_site_constraint(self):
12291229

12301230
self.assertHttpStatus(response, status.HTTP_400_BAD_REQUEST)
12311231

1232+
def test_rack_fit(self):
1233+
"""
1234+
Check that creating multiple devices with overlapping position fails.
1235+
"""
1236+
device = Device.objects.first()
1237+
device_type = DeviceType.objects.all()[1]
1238+
data = [
1239+
{
1240+
'device_type': device_type.pk,
1241+
'device_role': device.device_role.pk,
1242+
'site': device.site.pk,
1243+
'name': 'Test Device 7',
1244+
'rack': device.rack.pk,
1245+
'face': 'front',
1246+
'position': 1
1247+
},
1248+
{
1249+
'device_type': device_type.pk,
1250+
'device_role': device.device_role.pk,
1251+
'site': device.site.pk,
1252+
'name': 'Test Device 8',
1253+
'rack': device.rack.pk,
1254+
'face': 'front',
1255+
'position': 2
1256+
}
1257+
]
1258+
1259+
self.add_permissions('dcim.add_device')
1260+
url = reverse('dcim-api:device-list')
1261+
response = self.client.post(url, data, format='json', **self.header)
1262+
1263+
self.assertHttpStatus(response, status.HTTP_400_BAD_REQUEST)
1264+
12321265

12331266
class ModuleTest(APIViewTestCases.APIViewTestCase):
12341267
model = Module

0 commit comments

Comments
 (0)