mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-27 10:58:37 -06:00
17170 test fixes
This commit is contained in:
parent
e331be39f9
commit
82233c1e3e
@ -3,7 +3,7 @@ from drf_spectacular.types import OpenApiTypes
|
|||||||
from drf_spectacular.utils import extend_schema_field
|
from drf_spectacular.utils import extend_schema_field
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
from netbox.api.fields import ChoiceField, ContentTypeField
|
from netbox.api.fields import ChoiceField, ContentTypeField, SerializedPKRelatedField
|
||||||
from netbox.api.serializers import NestedGroupModelSerializer, NetBoxModelSerializer
|
from netbox.api.serializers import NestedGroupModelSerializer, NetBoxModelSerializer
|
||||||
from tenancy.choices import ContactPriorityChoices
|
from tenancy.choices import ContactPriorityChoices
|
||||||
from tenancy.models import ContactAssignment, Contact, ContactGroup, ContactRole
|
from tenancy.models import ContactAssignment, Contact, ContactGroup, ContactRole
|
||||||
@ -43,7 +43,12 @@ class ContactRoleSerializer(NetBoxModelSerializer):
|
|||||||
|
|
||||||
|
|
||||||
class ContactSerializer(NetBoxModelSerializer):
|
class ContactSerializer(NetBoxModelSerializer):
|
||||||
groups = ContactGroupSerializer(many=True, nested=True, required=False, allow_null=True, default=None)
|
groups = SerializedPKRelatedField(
|
||||||
|
queryset=ContactGroup.objects.all(),
|
||||||
|
serializer=ContactGroupSerializer,
|
||||||
|
required=False,
|
||||||
|
many=True
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Contact
|
model = Contact
|
||||||
|
@ -170,7 +170,7 @@ class ContactTest(APIViewTestCases.APIViewTestCase):
|
|||||||
model = Contact
|
model = Contact
|
||||||
brief_fields = ['description', 'display', 'id', 'name', 'url']
|
brief_fields = ['description', 'display', 'id', 'name', 'url']
|
||||||
bulk_update_data = {
|
bulk_update_data = {
|
||||||
'groups': None,
|
'groups': [],
|
||||||
'comments': 'New comments',
|
'comments': 'New comments',
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,11 +195,9 @@ class ContactTest(APIViewTestCases.APIViewTestCase):
|
|||||||
cls.create_data = [
|
cls.create_data = [
|
||||||
{
|
{
|
||||||
'name': 'Contact 4',
|
'name': 'Contact 4',
|
||||||
'groups': [contact_groups[1].pk],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'name': 'Contact 5',
|
'name': 'Contact 5',
|
||||||
'groups': [contact_groups[1].pk],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'name': 'Contact 6',
|
'name': 'Contact 6',
|
||||||
|
Loading…
Reference in New Issue
Block a user