Skip to content

Commit 6d1004a

Browse files
authored
Merge branch 'feature' into fix-testing
2 parents 320b8c7 + 5bd261e commit 6d1004a

File tree

5 files changed

+753
-23
lines changed

5 files changed

+753
-23
lines changed

.github/workflows/lint-tests.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ jobs:
6969
with:
7070
repository: "netbox-community/netbox"
7171
path: netbox
72+
ref: feature
7273
- name: Install netbox-custom-objects
7374
working-directory: netbox-custom-objects
7475
run: |

netbox_custom_objects/tests/base.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Test utilities for netbox_custom_objects plugin
2-
from django.contrib.contenttypes.models import ContentType
32
from django.test import Client
3+
from core.models import ObjectType
44
from extras.models import CustomFieldChoiceSet
55
from utilities.testing import create_test_user
66

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

6363
@classmethod
64-
def get_device_content_type(cls):
64+
def get_device_object_type(cls):
6565
"""Get the device content type for object field testing."""
66-
return ContentType.objects.get(app_label='dcim', model='device')
66+
return ObjectType.objects.get(app_label='dcim', model='device')
6767

6868
@classmethod
69-
def get_site_content_type(cls):
69+
def get_site_object_type(cls):
7070
"""Get the site content type for object field testing."""
71-
return ContentType.objects.get(app_label='dcim', model='site')
71+
return ObjectType.objects.get(app_label='dcim', model='site')
7272

7373
def create_simple_custom_object_type(self, **kwargs):
7474
"""Create a simple custom object type with basic fields."""
@@ -99,7 +99,7 @@ def create_complex_custom_object_type(self, **kwargs):
9999
"""Create a complex custom object type with various field types."""
100100
custom_object_type = CustomObjectsTestCase.create_custom_object_type(**kwargs)
101101
choice_set = CustomObjectsTestCase.create_choice_set()
102-
device_content_type = CustomObjectsTestCase.get_device_content_type()
102+
device_object_type = CustomObjectsTestCase.get_device_object_type()
103103

104104
# Primary text field
105105
CustomObjectsTestCase.create_custom_object_type_field(
@@ -145,7 +145,7 @@ def create_complex_custom_object_type(self, **kwargs):
145145
name="device",
146146
label="Device",
147147
type="object",
148-
related_object_type=device_content_type
148+
related_object_type=device_object_type
149149
)
150150

151151
return custom_object_type
@@ -169,8 +169,8 @@ def create_self_referential_custom_object_type(self, **kwargs):
169169
def create_multi_object_custom_object_type(self, **kwargs):
170170
"""Create a custom object type with multi-object fields."""
171171
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()
172+
device_object_type = CustomObjectsTestCase.get_device_object_type()
173+
site_object_type = CustomObjectsTestCase.get_site_object_type()
174174

175175
# Primary text field
176176
CustomObjectsTestCase.create_custom_object_type_field(
@@ -188,7 +188,7 @@ def create_multi_object_custom_object_type(self, **kwargs):
188188
name="devices",
189189
label="Devices",
190190
type="multiobject",
191-
related_object_type=device_content_type
191+
related_object_type=device_object_type
192192
)
193193

194194
# Multi-object field (sites)
@@ -197,7 +197,7 @@ def create_multi_object_custom_object_type(self, **kwargs):
197197
name="sites",
198198
label="Sites",
199199
type="multiobject",
200-
related_object_type=site_content_type
200+
related_object_type=site_object_type
201201
)
202202

203203
return custom_object_type

netbox_custom_objects/tests/test_field_types.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ class ObjectFieldTypeTestCase(FieldTypeTestCase):
602602
def setUp(self):
603603
"""Set up test data."""
604604
super().setUp()
605-
self.device_content_type = self.get_device_content_type()
605+
self.device_object_type = self.get_device_object_type()
606606

607607
def test_object_field_creation(self):
608608
"""Test creating an object field."""
@@ -611,11 +611,11 @@ def test_object_field_creation(self):
611611
name="device",
612612
label="Device",
613613
type="object",
614-
related_object_type=self.device_content_type
614+
related_object_type=self.device_object_type
615615
)
616616

617617
self.assertEqual(field.type, "object")
618-
self.assertEqual(field.related_object_type, self.device_content_type)
618+
self.assertEqual(field.related_object_type, self.device_object_type)
619619

620620
def test_object_field_model_generation(self):
621621
"""Test object field model generation."""
@@ -624,7 +624,7 @@ def test_object_field_model_generation(self):
624624
name="device",
625625
label="Device",
626626
type="object",
627-
related_object_type=self.device_content_type
627+
related_object_type=self.device_object_type
628628
)
629629
field # To silence ruff error
630630

@@ -661,7 +661,7 @@ class MultiObjectFieldTypeTestCase(FieldTypeTestCase):
661661
def setUp(self):
662662
"""Set up test data."""
663663
super().setUp()
664-
self.device_content_type = self.get_device_content_type()
664+
self.device_object_type = self.get_device_object_type()
665665

666666
def test_multiobject_field_creation(self):
667667
"""Test creating a multiobject field."""
@@ -670,11 +670,11 @@ def test_multiobject_field_creation(self):
670670
name="devices",
671671
label="Devices",
672672
type="multiobject",
673-
related_object_type=self.device_content_type
673+
related_object_type=self.device_object_type
674674
)
675675

676676
self.assertEqual(field.type, "multiobject")
677-
self.assertEqual(field.related_object_type, self.device_content_type)
677+
self.assertEqual(field.related_object_type, self.device_object_type)
678678

679679
def test_multiobject_field_model_generation(self):
680680
"""Test multiobject field model generation."""
@@ -683,7 +683,7 @@ def test_multiobject_field_model_generation(self):
683683
name="devices",
684684
label="Devices",
685685
type="multiobject",
686-
related_object_type=self.device_content_type
686+
related_object_type=self.device_object_type
687687
)
688688
field # To silence ruff error
689689

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)