test_views.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. from tenancy.models import Tenant, TenantGroup
  2. from utilities.testing import ViewTestCases
  3. class TenantGroupTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
  4. model = TenantGroup
  5. @classmethod
  6. def setUpTestData(cls):
  7. tenant_groups = (
  8. TenantGroup(name='Tenant Group 1', slug='tenant-group-1'),
  9. TenantGroup(name='Tenant Group 2', slug='tenant-group-2'),
  10. TenantGroup(name='Tenant Group 3', slug='tenant-group-3'),
  11. )
  12. for tenanantgroup in tenant_groups:
  13. tenanantgroup.save()
  14. cls.form_data = {
  15. 'name': 'Tenant Group X',
  16. 'slug': 'tenant-group-x',
  17. 'description': 'A new tenant group',
  18. }
  19. cls.csv_data = (
  20. "name,slug,description",
  21. "Tenant Group 4,tenant-group-4,Fourth tenant group",
  22. "Tenant Group 5,tenant-group-5,Fifth tenant group",
  23. "Tenant Group 6,tenant-group-6,Sixth tenant group",
  24. )
  25. class TenantTestCase(ViewTestCases.PrimaryObjectViewTestCase):
  26. model = Tenant
  27. @classmethod
  28. def setUpTestData(cls):
  29. tenant_groups = (
  30. TenantGroup(name='Tenant Group 1', slug='tenant-group-1'),
  31. TenantGroup(name='Tenant Group 2', slug='tenant-group-2'),
  32. )
  33. for tenanantgroup in tenant_groups:
  34. tenanantgroup.save()
  35. Tenant.objects.bulk_create([
  36. Tenant(name='Tenant 1', slug='tenant-1', group=tenant_groups[0]),
  37. Tenant(name='Tenant 2', slug='tenant-2', group=tenant_groups[0]),
  38. Tenant(name='Tenant 3', slug='tenant-3', group=tenant_groups[0]),
  39. ])
  40. cls.form_data = {
  41. 'name': 'Tenant X',
  42. 'slug': 'tenant-x',
  43. 'group': tenant_groups[1].pk,
  44. 'description': 'A new tenant',
  45. 'comments': 'Some comments',
  46. 'tags': 'Alpha,Bravo,Charlie',
  47. }
  48. cls.csv_data = (
  49. "name,slug",
  50. "Tenant 4,tenant-4",
  51. "Tenant 5,tenant-5",
  52. "Tenant 6,tenant-6",
  53. )
  54. cls.bulk_edit_data = {
  55. 'group': tenant_groups[1].pk,
  56. }