Пример #1
0
 def test__get_permissions_without_active_user(self):
     set_current_tenant(self.tenant.slug)
     self.user.is_active = False
     self.user.save()
     auth_backend = TenantModelBackend()
     self.assertEqual(
         len(auth_backend._get_permissions(self.user, None, 'group')), 0)
 def test__get_permissions(self):
     set_current_tenant(self.tenant.slug)
     auth_backend = TenantModelBackend()
     self.assertEqual(
         len(auth_backend._get_permissions(self.user, None, 'group')),
         self.relationship.groups.first().permissions.count()
     )
 def test__get_permissions_without_tenant(self):
     clear_current_tenant()
     auth_backend = TenantModelBackend()
     self.assertEqual(
         len(auth_backend._get_permissions(self.user, None, 'group')),
         0
     )
Пример #4
0
 def test__get_permissions_with_superuser(self):
     set_current_tenant(self.tenant.slug)
     self.user.is_superuser = True
     self.user.save()
     auth_backend = TenantModelBackend()
     self.assertEqual(
         len(auth_backend._get_permissions(self.user, None, 'group')),
         Permission.objects.all().count())
 def test__get_permissions_without_user_in_tenant(self):
     set_current_tenant(self.tenant.slug)
     self.user.relationships.all().delete()
     auth_backend = TenantModelBackend()
     self.assertEqual(
         len(auth_backend._get_permissions(self.user, None, 'group')),
         0
     )