mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-12 10:38:16 -06:00
Fix test
This commit is contained in:
parent
547f7c3dab
commit
8aea160bda
@ -5,8 +5,11 @@ from django.urls import reverse
|
|||||||
|
|
||||||
from circuits.choices import *
|
from circuits.choices import *
|
||||||
from circuits.models import *
|
from circuits.models import *
|
||||||
|
from core.models import ObjectType
|
||||||
from dcim.models import Cable, Interface, Site
|
from dcim.models import Cable, Interface, Site
|
||||||
from ipam.models import ASN, RIR
|
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
|
from utilities.testing import ViewTestCases, create_tags, create_test_device
|
||||||
|
|
||||||
|
|
||||||
@ -185,50 +188,50 @@ class CircuitTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
'comments': 'New comments',
|
'comments': 'New comments',
|
||||||
}
|
}
|
||||||
|
|
||||||
@override_settings(EXEMPT_VIEW_PERMISSIONS=['*'], EXEMPT_EXCLUDE_MODELS=[])
|
@override_settings(EXEMPT_VIEW_PERMISSIONS=['*'], EXEMPT_EXCLUDE_MODELS=[])
|
||||||
def test_bulk_import_objects_with_terminations(self):
|
def test_bulk_import_objects_with_terminations(self):
|
||||||
json_data = """
|
json_data = """
|
||||||
[
|
[
|
||||||
|
{
|
||||||
|
"cid": "Circuit 7",
|
||||||
|
"provider": "Provider 1",
|
||||||
|
"type": "Circuit Type 1",
|
||||||
|
"status": "active",
|
||||||
|
"description": "Testing Import",
|
||||||
|
"terminations": [
|
||||||
{
|
{
|
||||||
"cid": "Circuit 7",
|
"term_side": "A",
|
||||||
"provider": "Provider1",
|
"site": "Site 1"
|
||||||
"type": "Circuit Type 1",
|
},
|
||||||
"status": "active",
|
{
|
||||||
"description": "Testing Import",
|
"term_side": "Z",
|
||||||
"terminations": [
|
"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,
|
initial_count = self._get_queryset().count()
|
||||||
'format': ImportFormatChoices.JSON,
|
data = {
|
||||||
}
|
'data': json_data,
|
||||||
|
'format': ImportFormatChoices.JSON,
|
||||||
|
}
|
||||||
|
|
||||||
# Assign model-level permission
|
# Assign model-level permission
|
||||||
obj_perm = ObjectPermission(
|
obj_perm = ObjectPermission(
|
||||||
name='Test permission',
|
name='Test permission',
|
||||||
actions=['add']
|
actions=['add']
|
||||||
)
|
)
|
||||||
obj_perm.save()
|
obj_perm.save()
|
||||||
obj_perm.users.add(self.user)
|
obj_perm.users.add(self.user)
|
||||||
obj_perm.object_types.add(ObjectType.objects.get_for_model(self.model))
|
obj_perm.object_types.add(ObjectType.objects.get_for_model(self.model))
|
||||||
|
|
||||||
# Try GET with model-level permission
|
# Try GET with model-level permission
|
||||||
self.assertHttpStatus(self.client.get(self._get_url('import')), 200)
|
self.assertHttpStatus(self.client.get(self._get_url('import')), 200)
|
||||||
|
|
||||||
# Test POST with permission
|
# Test POST with permission
|
||||||
self.assertHttpStatus(self.client.post(self._get_url('import'), data), 302)
|
self.assertHttpStatus(self.client.post(self._get_url('import'), data), 302)
|
||||||
self.assertEqual(self._get_queryset().count(), initial_count + 1)
|
self.assertEqual(self._get_queryset().count(), initial_count + 1)
|
||||||
|
|
||||||
|
|
||||||
class ProviderAccountTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
class ProviderAccountTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
||||||
|
Loading…
Reference in New Issue
Block a user