mirror of
https://github.com/netbox-community/netbox.git
synced 2026-03-23 18:01:37 +01:00
Closes #1846: Enable MPTT for InventoryItem hierarchy
This commit is contained in:
@@ -1273,7 +1273,7 @@ class DeviceBayTest(APIViewTestCases.APIViewTestCase):
|
||||
|
||||
class InventoryItemTest(APIViewTestCases.APIViewTestCase):
|
||||
model = InventoryItem
|
||||
brief_fields = ['device', 'id', 'name', 'url']
|
||||
brief_fields = ['_depth', 'device', 'id', 'name', 'url']
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
@@ -1283,12 +1283,9 @@ class InventoryItemTest(APIViewTestCases.APIViewTestCase):
|
||||
devicerole = DeviceRole.objects.create(name='Test Device Role 1', slug='test-device-role-1', color='ff0000')
|
||||
device = Device.objects.create(device_type=devicetype, device_role=devicerole, name='Device 1', site=site)
|
||||
|
||||
inventory_items = (
|
||||
InventoryItem(device=device, name='Inventory Item 1', manufacturer=manufacturer),
|
||||
InventoryItem(device=device, name='Inventory Item 2', manufacturer=manufacturer),
|
||||
InventoryItem(device=device, name='Inventory Item 3', manufacturer=manufacturer),
|
||||
)
|
||||
InventoryItem.objects.bulk_create(inventory_items)
|
||||
InventoryItem.objects.create(device=device, name='Inventory Item 1', manufacturer=manufacturer)
|
||||
InventoryItem.objects.create(device=device, name='Inventory Item 2', manufacturer=manufacturer)
|
||||
InventoryItem.objects.create(device=device, name='Inventory Item 3', manufacturer=manufacturer)
|
||||
|
||||
cls.create_data = [
|
||||
{
|
||||
|
||||
@@ -2285,14 +2285,16 @@ class InventoryItemTestCase(TestCase):
|
||||
InventoryItem(device=devices[1], manufacturer=manufacturers[1], name='Inventory Item 2', part_id='1002', serial='DEF', asset_tag='1002', discovered=True, description='Second'),
|
||||
InventoryItem(device=devices[2], manufacturer=manufacturers[2], name='Inventory Item 3', part_id='1003', serial='GHI', asset_tag='1003', discovered=False, description='Third'),
|
||||
)
|
||||
InventoryItem.objects.bulk_create(inventory_items)
|
||||
for i in inventory_items:
|
||||
i.save()
|
||||
|
||||
child_inventory_items = (
|
||||
InventoryItem(device=devices[0], name='Inventory Item 1A', parent=inventory_items[0]),
|
||||
InventoryItem(device=devices[1], name='Inventory Item 2A', parent=inventory_items[1]),
|
||||
InventoryItem(device=devices[2], name='Inventory Item 3A', parent=inventory_items[2]),
|
||||
)
|
||||
InventoryItem.objects.bulk_create(child_inventory_items)
|
||||
for i in child_inventory_items:
|
||||
i.save()
|
||||
|
||||
def test_id(self):
|
||||
params = {'id': self.queryset.values_list('pk', flat=True)[:2]}
|
||||
|
||||
@@ -1430,11 +1430,9 @@ class InventoryItemTestCase(ViewTestCases.DeviceComponentViewTestCase):
|
||||
device = create_test_device('Device 1')
|
||||
manufacturer, _ = Manufacturer.objects.get_or_create(name='Manufacturer 1', slug='manufacturer-1')
|
||||
|
||||
InventoryItem.objects.bulk_create([
|
||||
InventoryItem(device=device, name='Inventory Item 1'),
|
||||
InventoryItem(device=device, name='Inventory Item 2'),
|
||||
InventoryItem(device=device, name='Inventory Item 3'),
|
||||
])
|
||||
InventoryItem.objects.create(device=device, name='Inventory Item 1')
|
||||
InventoryItem.objects.create(device=device, name='Inventory Item 2')
|
||||
InventoryItem.objects.create(device=device, name='Inventory Item 3')
|
||||
|
||||
tags = cls.create_tags('Alpha', 'Bravo', 'Charlie')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user