Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions netbox_custom_objects/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.test import TestCase, RequestFactory
from django.urls import reverse

from utilities.testing import create_test_user
from utilities.testing import TestCase as NetBoxTestCase, create_test_user
from rest_framework import status
from rest_framework.test import APIClient

Expand Down Expand Up @@ -115,7 +115,7 @@ def test_delete_object_without_permission(self):
self.assertHttpStatus(response, 403)


class CustomObjectTest(CustomObjectsTestCase, CustomObjectAPITestCaseMixin, TestCase):
class CustomObjectTest(CustomObjectsTestCase, CustomObjectAPITestCaseMixin, NetBoxTestCase):
model = None # Will be set in setUpTestData
bulk_update_data = {
'test_field': 'Updated test field',
Expand Down Expand Up @@ -388,6 +388,7 @@ def test_create_with_nested_serializers(self):
obj_perm.save()
obj_perm.users.add(self.user)
obj_perm.object_types.add(ObjectType.objects.get_for_model(self.model))
self.add_permissions('dcim.view_device')

devices = Device.objects.all()

Expand Down Expand Up @@ -418,6 +419,7 @@ def test_create_with_nested_serializers(self):
def test_create_with_tags_persists_to_db(self):
"""Regression #371: tags submitted on POST must be saved to the DB, not just echoed."""
self._add_permission('add', 'Create with tags perm')
self.add_permissions('extras.view_tag')
tag = Tag.objects.get_or_create(name='api-create-tag', slug='api-create-tag')[0]

data = {
Expand All @@ -437,6 +439,7 @@ def test_patch_with_tags_persists_to_db(self):
"""Regression #371: tags submitted on PATCH must be saved to the DB, not just echoed."""
self._add_permission('view', 'View perm')
self._add_permission('change', 'Patch with tags perm')
self.add_permissions('extras.view_tag')
tag = Tag.objects.get_or_create(name='api-patch-tag', slug='api-patch-tag')[0]

instance = self._get_queryset().first()
Expand Down Expand Up @@ -1592,6 +1595,7 @@ def _add_perm(self, action, model):
def test_patch_updates_cross_cot_m2m_field(self):
"""#443 – PATCH with a list of target PKs must update the M2M field."""
self._add_perm('change', self.model_source)
self._add_perm('view', self.model_target)

# Confirm initial state.
self.assertSetEqual(
Expand Down