diff --git a/netbox/circuits/tests/test_views.py b/netbox/circuits/tests/test_views.py index 45b9e935a..577548703 100644 --- a/netbox/circuits/tests/test_views.py +++ b/netbox/circuits/tests/test_views.py @@ -5,8 +5,11 @@ from django.urls import reverse from circuits.choices import * from circuits.models import * +from core.models import ObjectType from dcim.models import Cable, Interface, Site from ipam.models import ASN, RIR +from netbox.choices import ImportFormatChoices +from users.models import ObjectPermission from utilities.testing import ViewTestCases, create_tags, create_test_device @@ -185,50 +188,50 @@ class CircuitTestCase(ViewTestCases.PrimaryObjectViewTestCase): 'comments': 'New comments', } - @override_settings(EXEMPT_VIEW_PERMISSIONS=['*'], EXEMPT_EXCLUDE_MODELS=[]) - def test_bulk_import_objects_with_terminations(self): - json_data = """ - [ + @override_settings(EXEMPT_VIEW_PERMISSIONS=['*'], EXEMPT_EXCLUDE_MODELS=[]) + def test_bulk_import_objects_with_terminations(self): + json_data = """ + [ + { + "cid": "Circuit 7", + "provider": "Provider 1", + "type": "Circuit Type 1", + "status": "active", + "description": "Testing Import", + "terminations": [ { - "cid": "Circuit 7", - "provider": "Provider1", - "type": "Circuit Type 1", - "status": "active", - "description": "Testing Import", - "terminations": [ - { - "term_side": "A", - "site": "Site 1" - }, - { - "term_side": "Z", - "site": "Site 1" - } - ] + "term_side": "A", + "site": "Site 1" + }, + { + "term_side": "Z", + "site": "Site 1" } ] - """ - initial_count = self._get_queryset().count() - data = { - 'data': json_data, - 'format': ImportFormatChoices.JSON, - } + } + ] + """ + initial_count = self._get_queryset().count() + data = { + 'data': json_data, + 'format': ImportFormatChoices.JSON, + } - # Assign model-level permission - obj_perm = ObjectPermission( - name='Test permission', - actions=['add'] - ) - obj_perm.save() - obj_perm.users.add(self.user) - obj_perm.object_types.add(ObjectType.objects.get_for_model(self.model)) + # Assign model-level permission + obj_perm = ObjectPermission( + name='Test permission', + actions=['add'] + ) + obj_perm.save() + obj_perm.users.add(self.user) + obj_perm.object_types.add(ObjectType.objects.get_for_model(self.model)) - # Try GET with model-level permission - self.assertHttpStatus(self.client.get(self._get_url('import')), 200) + # Try GET with model-level permission + self.assertHttpStatus(self.client.get(self._get_url('import')), 200) - # Test POST with permission - self.assertHttpStatus(self.client.post(self._get_url('import'), data), 302) - self.assertEqual(self._get_queryset().count(), initial_count + 1) + # Test POST with permission + self.assertHttpStatus(self.client.post(self._get_url('import'), data), 302) + self.assertEqual(self._get_queryset().count(), initial_count + 1) class ProviderAccountTestCase(ViewTestCases.PrimaryObjectViewTestCase):