Jeremy Stretch 5 лет назад
Родитель
Сommit
4f830c9c22

+ 1 - 0
netbox/dcim/api/nested_serializers.py

@@ -302,6 +302,7 @@ class NestedDeviceBaySerializer(WritableNestedSerializer):
 
 
 class NestedInventoryItemSerializer(WritableNestedSerializer):
 class NestedInventoryItemSerializer(WritableNestedSerializer):
     url = serializers.HyperlinkedIdentityField(view_name='dcim-api:inventoryitem-detail')
     url = serializers.HyperlinkedIdentityField(view_name='dcim-api:inventoryitem-detail')
+    device = NestedDeviceSerializer(read_only=True)
 
 
     class Meta:
     class Meta:
         model = models.InventoryItem
         model = models.InventoryItem

+ 2 - 1
netbox/dcim/tests/test_api.py

@@ -289,6 +289,7 @@ class RackTest(APIViewTestCases.APIViewTestCase):
 
 
 class RackReservationTest(APIViewTestCases.APIViewTestCase):
 class RackReservationTest(APIViewTestCases.APIViewTestCase):
     model = RackReservation
     model = RackReservation
+    brief_fields = ['id', 'units', 'url', 'user']
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):
@@ -1303,7 +1304,7 @@ class DeviceBayTest(APIViewTestCases.APIViewTestCase):
 
 
 class InventoryItemTest(APIViewTestCases.APIViewTestCase):
 class InventoryItemTest(APIViewTestCases.APIViewTestCase):
     model = InventoryItem
     model = InventoryItem
-    brief_fields = ['id', 'name', 'url']
+    brief_fields = ['device', 'id', 'name', 'url']
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):

+ 5 - 2
netbox/extras/tests/test_api.py

@@ -5,11 +5,10 @@ from django.urls import reverse
 from django.utils import timezone
 from django.utils import timezone
 from rest_framework import status
 from rest_framework import status
 
 
-from dcim.models import Device, DeviceRole, DeviceType, Manufacturer, Platform, Rack, RackGroup, RackRole, Region, Site
+from dcim.models import Device, DeviceRole, DeviceType, Manufacturer, Rack, RackGroup, RackRole, Site
 from extras.api.views import ScriptViewSet
 from extras.api.views import ScriptViewSet
 from extras.models import ConfigContext, Graph, ExportTemplate, Tag
 from extras.models import ConfigContext, Graph, ExportTemplate, Tag
 from extras.scripts import BooleanVar, IntegerVar, Script, StringVar
 from extras.scripts import BooleanVar, IntegerVar, Script, StringVar
-from tenancy.models import Tenant, TenantGroup
 from utilities.testing import APITestCase, APIViewTestCases
 from utilities.testing import APITestCase, APIViewTestCases
 
 
 
 
@@ -25,6 +24,7 @@ class AppTest(APITestCase):
 
 
 class GraphTest(APIViewTestCases.APIViewTestCase):
 class GraphTest(APIViewTestCases.APIViewTestCase):
     model = Graph
     model = Graph
+    brief_fields = ['id', 'name', 'url']
     create_data = [
     create_data = [
         {
         {
             'type': 'dcim.site',
             'type': 'dcim.site',
@@ -57,6 +57,7 @@ class GraphTest(APIViewTestCases.APIViewTestCase):
 
 
 class ExportTemplateTest(APIViewTestCases.APIViewTestCase):
 class ExportTemplateTest(APIViewTestCases.APIViewTestCase):
     model = ExportTemplate
     model = ExportTemplate
+    brief_fields = ['id', 'name', 'url']
     create_data = [
     create_data = [
         {
         {
             'content_type': 'dcim.device',
             'content_type': 'dcim.device',
@@ -101,6 +102,7 @@ class ExportTemplateTest(APIViewTestCases.APIViewTestCase):
 
 
 class TagTest(APIViewTestCases.APIViewTestCase):
 class TagTest(APIViewTestCases.APIViewTestCase):
     model = Tag
     model = Tag
+    brief_fields = ['color', 'id', 'name', 'slug', 'tagged_items', 'url']
     create_data = [
     create_data = [
         {
         {
             'name': 'Tag 4',
             'name': 'Tag 4',
@@ -129,6 +131,7 @@ class TagTest(APIViewTestCases.APIViewTestCase):
 
 
 class ConfigContextTest(APIViewTestCases.APIViewTestCase):
 class ConfigContextTest(APIViewTestCases.APIViewTestCase):
     model = ConfigContext
     model = ConfigContext
+    brief_fields = ['id', 'name', 'url']
     create_data = [
     create_data = [
         {
         {
             'name': 'Config Context 4',
             'name': 'Config Context 4',

+ 1 - 0
netbox/ipam/tests/test_api.py

@@ -424,6 +424,7 @@ class VLANTest(APIViewTestCases.APIViewTestCase):
 
 
 class ServiceTest(APIViewTestCases.APIViewTestCase):
 class ServiceTest(APIViewTestCases.APIViewTestCase):
     model = Service
     model = Service
+    brief_fields = ['id', 'name', 'port', 'protocol', 'url']
 
 
     @classmethod
     @classmethod
     def setUpTestData(cls):
     def setUpTestData(cls):