1
1
# Test utilities for netbox_custom_objects plugin
2
2
from django .contrib .contenttypes .models import ContentType
3
3
from django .test import Client
4
+ from core .models import ObjectType
4
5
from extras .models import CustomFieldChoiceSet
5
6
from utilities .testing import create_test_user
6
7
@@ -61,14 +62,14 @@ def create_choice_set(cls, **kwargs):
61
62
return CustomFieldChoiceSet .objects .create (** defaults )
62
63
63
64
@classmethod
64
- def get_device_content_type (cls ):
65
+ def get_device_object_type (cls ):
65
66
"""Get the device content type for object field testing."""
66
- return ContentType .objects .get (app_label = 'dcim' , model = 'device' )
67
+ return ObjectType .objects .get (app_label = 'dcim' , model = 'device' )
67
68
68
69
@classmethod
69
- def get_site_content_type (cls ):
70
+ def get_site_object_type (cls ):
70
71
"""Get the site content type for object field testing."""
71
- return ContentType .objects .get (app_label = 'dcim' , model = 'site' )
72
+ return ObjectType .objects .get (app_label = 'dcim' , model = 'site' )
72
73
73
74
def create_simple_custom_object_type (self , ** kwargs ):
74
75
"""Create a simple custom object type with basic fields."""
@@ -99,7 +100,7 @@ def create_complex_custom_object_type(self, **kwargs):
99
100
"""Create a complex custom object type with various field types."""
100
101
custom_object_type = CustomObjectsTestCase .create_custom_object_type (** kwargs )
101
102
choice_set = CustomObjectsTestCase .create_choice_set ()
102
- device_content_type = CustomObjectsTestCase .get_device_content_type ()
103
+ device_object_type = CustomObjectsTestCase .get_device_object_type ()
103
104
104
105
# Primary text field
105
106
CustomObjectsTestCase .create_custom_object_type_field (
@@ -145,7 +146,7 @@ def create_complex_custom_object_type(self, **kwargs):
145
146
name = "device" ,
146
147
label = "Device" ,
147
148
type = "object" ,
148
- related_object_type = device_content_type
149
+ related_object_type = device_object_type
149
150
)
150
151
151
152
return custom_object_type
@@ -169,8 +170,8 @@ def create_self_referential_custom_object_type(self, **kwargs):
169
170
def create_multi_object_custom_object_type (self , ** kwargs ):
170
171
"""Create a custom object type with multi-object fields."""
171
172
custom_object_type = CustomObjectsTestCase .create_custom_object_type (** kwargs )
172
- device_content_type = CustomObjectsTestCase .get_device_content_type ()
173
- site_content_type = CustomObjectsTestCase .get_site_content_type ()
173
+ device_object_type = CustomObjectsTestCase .get_device_object_type ()
174
+ site_object_type = CustomObjectsTestCase .get_site_object_type ()
174
175
175
176
# Primary text field
176
177
CustomObjectsTestCase .create_custom_object_type_field (
@@ -188,7 +189,7 @@ def create_multi_object_custom_object_type(self, **kwargs):
188
189
name = "devices" ,
189
190
label = "Devices" ,
190
191
type = "multiobject" ,
191
- related_object_type = device_content_type
192
+ related_object_type = device_object_type
192
193
)
193
194
194
195
# Multi-object field (sites)
@@ -197,7 +198,7 @@ def create_multi_object_custom_object_type(self, **kwargs):
197
198
name = "sites" ,
198
199
label = "Sites" ,
199
200
type = "multiobject" ,
200
- related_object_type = site_content_type
201
+ related_object_type = site_object_type
201
202
)
202
203
203
204
return custom_object_type
0 commit comments