Skip to content

Commit 3c74f71

Browse files
committed
Change ContentType refs to ObjectType
1 parent c820dc4 commit 3c74f71

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

netbox_custom_objects/tests/base.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Test utilities for netbox_custom_objects plugin
22
from django.contrib.contenttypes.models import ContentType
33
from django.test import Client
4+
from core.models import ObjectType
45
from extras.models import CustomFieldChoiceSet
56
from utilities.testing import create_test_user
67

@@ -61,14 +62,14 @@ def create_choice_set(cls, **kwargs):
6162
return CustomFieldChoiceSet.objects.create(**defaults)
6263

6364
@classmethod
64-
def get_device_content_type(cls):
65+
def get_device_object_type(cls):
6566
"""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')
6768

6869
@classmethod
69-
def get_site_content_type(cls):
70+
def get_site_object_type(cls):
7071
"""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')
7273

7374
def create_simple_custom_object_type(self, **kwargs):
7475
"""Create a simple custom object type with basic fields."""
@@ -99,7 +100,7 @@ def create_complex_custom_object_type(self, **kwargs):
99100
"""Create a complex custom object type with various field types."""
100101
custom_object_type = CustomObjectsTestCase.create_custom_object_type(**kwargs)
101102
choice_set = CustomObjectsTestCase.create_choice_set()
102-
device_content_type = CustomObjectsTestCase.get_device_content_type()
103+
device_object_type = CustomObjectsTestCase.get_device_object_type()
103104

104105
# Primary text field
105106
CustomObjectsTestCase.create_custom_object_type_field(
@@ -145,7 +146,7 @@ def create_complex_custom_object_type(self, **kwargs):
145146
name="device",
146147
label="Device",
147148
type="object",
148-
related_object_type=device_content_type
149+
related_object_type=device_object_type
149150
)
150151

151152
return custom_object_type
@@ -169,8 +170,8 @@ def create_self_referential_custom_object_type(self, **kwargs):
169170
def create_multi_object_custom_object_type(self, **kwargs):
170171
"""Create a custom object type with multi-object fields."""
171172
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()
174175

175176
# Primary text field
176177
CustomObjectsTestCase.create_custom_object_type_field(
@@ -188,7 +189,7 @@ def create_multi_object_custom_object_type(self, **kwargs):
188189
name="devices",
189190
label="Devices",
190191
type="multiobject",
191-
related_object_type=device_content_type
192+
related_object_type=device_object_type
192193
)
193194

194195
# Multi-object field (sites)
@@ -197,7 +198,7 @@ def create_multi_object_custom_object_type(self, **kwargs):
197198
name="sites",
198199
label="Sites",
199200
type="multiobject",
200-
related_object_type=site_content_type
201+
related_object_type=site_object_type
201202
)
202203

203204
return custom_object_type

netbox_custom_objects/tests/test_models.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ def test_custom_object_type_field_object_type_validation(self):
303303
field.full_clean()
304304

305305
# Should not allow related_object_type for non-object field
306-
device_ct = self.get_device_content_type()
306+
device_ct = self.get_device_object_type()
307307
with self.assertRaises(ValidationError):
308308
field = CustomObjectTypeField(
309309
custom_object_type=self.custom_object_type,
@@ -463,7 +463,7 @@ def setUpTestData(cls):
463463
choice_set=choice_set,
464464
)
465465

466-
site_ct = cls.get_site_content_type()
466+
site_ct = cls.get_site_object_type()
467467
cls.create_custom_object_type_field(
468468
cls.custom_object_type,
469469
name="site",
@@ -472,7 +472,7 @@ def setUpTestData(cls):
472472
related_object_type=site_ct,
473473
)
474474

475-
site_ct = cls.get_site_content_type()
475+
site_ct = cls.get_site_object_type()
476476
cls.create_custom_object_type_field(
477477
cls.custom_object_type,
478478
name="sites",
@@ -492,7 +492,7 @@ def setUp(self):
492492
def test_custom_object_creation(self):
493493
"""Test creating a custom object instance."""
494494
now = timezone.now()
495-
site_ct = self.get_site_content_type()
495+
site_ct = self.get_site_object_type()
496496
site = site_ct.model_class().objects.create()
497497

498498
instance = self.model.objects.create(

0 commit comments

Comments
 (0)