2019-02-15 17:02:18 -05:00
|
|
|
from tenancy.models import Tenant, TenantGroup
|
2020-02-12 12:33:27 -05:00
|
|
|
from utilities.testing import ViewTestCases
|
2019-02-15 17:02:18 -05:00
|
|
|
|
|
|
|
|
2020-02-12 12:33:27 -05:00
|
|
|
class TenantGroupTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
|
2020-01-31 15:44:10 -05:00
|
|
|
model = TenantGroup
|
|
|
|
|
2020-01-30 16:37:40 -05:00
|
|
|
@classmethod
|
|
|
|
def setUpTestData(cls):
|
2019-02-15 17:02:18 -05:00
|
|
|
|
2020-03-11 21:14:53 -04:00
|
|
|
tenant_groups = (
|
2019-02-15 17:02:18 -05:00
|
|
|
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()
|
2019-02-15 17:02:18 -05:00
|
|
|
|
2020-01-31 15:44:10 -05:00
|
|
|
cls.form_data = {
|
|
|
|
'name': 'Tenant Group X',
|
|
|
|
'slug': 'tenant-group-x',
|
2020-03-13 16:24:37 -04:00
|
|
|
'description': 'A new tenant group',
|
2020-01-31 15:44:10 -05:00
|
|
|
}
|
2019-12-12 11:29:41 -05:00
|
|
|
|
2020-01-31 15:44:10 -05:00
|
|
|
cls.csv_data = (
|
2020-03-13 16:24:37 -04:00
|
|
|
"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
|
|
|
)
|
|
|
|
|
|
|
|
|
2020-02-12 12:33:27 -05:00
|
|
|
class TenantTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
2020-01-31 15:44:10 -05:00
|
|
|
model = Tenant
|
2019-02-15 17:02:18 -05:00
|
|
|
|
2020-01-30 16:37:40 -05:00
|
|
|
@classmethod
|
|
|
|
def setUpTestData(cls):
|
2019-02-15 17:02:18 -05:00
|
|
|
|
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()
|
2019-02-15 17:02:18 -05:00
|
|
|
|
|
|
|
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]),
|
2019-02-15 17:02:18 -05:00
|
|
|
])
|
|
|
|
|
2020-06-18 10:32:22 -04:00
|
|
|
tags = cls.create_tags('Alpha', 'Bravo', 'Charlie')
|
|
|
|
|
2020-01-31 15:44:10 -05:00
|
|
|
cls.form_data = {
|
|
|
|
'name': 'Tenant X',
|
|
|
|
'slug': 'tenant-x',
|
2020-03-11 21:14:53 -04:00
|
|
|
'group': tenant_groups[1].pk,
|
2020-01-31 15:44:10 -05:00
|
|
|
'description': 'A new tenant',
|
|
|
|
'comments': 'Some comments',
|
2020-06-18 10:32:22 -04:00
|
|
|
'tags': [t.pk for t in tags],
|
2019-02-15 17:02:18 -05:00
|
|
|
}
|
|
|
|
|
2020-01-31 15:44:10 -05:00
|
|
|
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
|
|
|
}
|