1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

71 lines
2.1 KiB
Python
Raw Normal View History

from tenancy.models import Tenant, TenantGroup
from utilities.testing import ViewTestCases
class TenantGroupTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
model = TenantGroup
@classmethod
def setUpTestData(cls):
2020-03-11 21:14:53 -04:00
tenant_groups = (
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'),
2020-03-11 21:14:53 -04:00
)
for tenanantgroup in tenant_groups:
tenanantgroup.save()
cls.form_data = {
'name': 'Tenant Group X',
'slug': 'tenant-group-x',
'description': 'A new tenant group',
}
2019-12-12 11:29:41 -05:00
cls.csv_data = (
"name,slug,description",
"Tenant Group 4,tenant-group-4,Fourth tenant group",
"Tenant Group 5,tenant-group-5,Fifth tenant group",
"Tenant Group 6,tenant-group-6,Sixth tenant group",
2019-12-12 11:29:41 -05:00
)
class TenantTestCase(ViewTestCases.PrimaryObjectViewTestCase):
model = Tenant
@classmethod
def setUpTestData(cls):
2020-03-11 21:14:53 -04:00
tenant_groups = (
2020-02-03 13:32:53 -05:00
TenantGroup(name='Tenant Group 1', slug='tenant-group-1'),
TenantGroup(name='Tenant Group 2', slug='tenant-group-2'),
)
2020-03-11 21:14:53 -04:00
for tenanantgroup in tenant_groups:
tenanantgroup.save()
Tenant.objects.bulk_create([
2020-03-11 21:14:53 -04:00
Tenant(name='Tenant 1', slug='tenant-1', group=tenant_groups[0]),
Tenant(name='Tenant 2', slug='tenant-2', group=tenant_groups[0]),
Tenant(name='Tenant 3', slug='tenant-3', group=tenant_groups[0]),
])
cls.form_data = {
'name': 'Tenant X',
'slug': 'tenant-x',
2020-03-11 21:14:53 -04:00
'group': tenant_groups[1].pk,
'description': 'A new tenant',
'comments': 'Some comments',
'tags': 'Alpha,Bravo,Charlie',
}
cls.csv_data = (
2019-12-12 11:29:41 -05:00
"name,slug",
"Tenant 4,tenant-4",
"Tenant 5,tenant-5",
"Tenant 6,tenant-6",
)
2020-02-03 13:32:53 -05:00
cls.bulk_edit_data = {
2020-03-11 21:14:53 -04:00
'group': tenant_groups[1].pk,
2020-02-03 13:32:53 -05:00
}