mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
63 lines
1.7 KiB
Python
63 lines
1.7 KiB
Python
from tenancy.models import Tenant, TenantGroup
|
|
from utilities.testing import StandardTestCases
|
|
|
|
|
|
class TenantGroupTestCase(StandardTestCases.Views):
|
|
model = TenantGroup
|
|
|
|
# Disable inapplicable tests
|
|
test_get_object = None
|
|
test_delete_object = None
|
|
|
|
@classmethod
|
|
def setUpTestData(cls):
|
|
|
|
TenantGroup.objects.bulk_create([
|
|
TenantGroup(name='Tenant Group 1', slug='tenant-group-1'),
|
|
TenantGroup(name='Tenant Group 2', slug='tenant-group-2'),
|
|
TenantGroup(name='Tenant Group 3', slug='tenant-group-3'),
|
|
])
|
|
|
|
cls.form_data = {
|
|
'name': 'Tenant Group X',
|
|
'slug': 'tenant-group-x',
|
|
}
|
|
|
|
cls.csv_data = (
|
|
"name,slug",
|
|
"Tenant Group 4,tenant-group-4",
|
|
"Tenant Group 5,tenant-group-5",
|
|
"Tenant Group 6,tenant-group-6",
|
|
)
|
|
|
|
|
|
class TenantTestCase(StandardTestCases.Views):
|
|
model = Tenant
|
|
|
|
@classmethod
|
|
def setUpTestData(cls):
|
|
|
|
tenantgroup = TenantGroup.objects.create(name='Tenant Group 1', slug='tenant-group-1')
|
|
|
|
Tenant.objects.bulk_create([
|
|
Tenant(name='Tenant 1', slug='tenant-1', group=tenantgroup),
|
|
Tenant(name='Tenant 2', slug='tenant-2', group=tenantgroup),
|
|
Tenant(name='Tenant 3', slug='tenant-3', group=tenantgroup),
|
|
])
|
|
|
|
cls.form_data = {
|
|
'name': 'Tenant X',
|
|
'slug': 'tenant-x',
|
|
'group': tenantgroup.pk,
|
|
'description': 'A new tenant',
|
|
'comments': 'Some comments',
|
|
'tags': 'Alpha,Bravo,Charlie',
|
|
}
|
|
|
|
cls.csv_data = (
|
|
"name,slug",
|
|
"Tenant 4,tenant-4",
|
|
"Tenant 5,tenant-5",
|
|
"Tenant 6,tenant-6",
|
|
)
|