def test_has_perm_unsupported_model(self): # Unsupported permission codename will raise PermissionNameError. user = self.factory.make_user() auth = PermissionAuth(user) with TestCase.assertRaises(self, PermissionNameError): GroupDevicePermission.objects.assign_perm("change_group", self.group, self.device)
def test_devicetype_manager_accessible_wrong_permission(self): with TestCase.assertRaises(self, ValueError): DeviceType.objects.all().accessible_by_user(self.user1, "non_existing_perm")
def test_assign_perm_wrong_permission_name(self): # Test wrong permission name when assigning permission. with TestCase.assertRaises(self, PermissionNameError): GroupDevicePermission.objects.assign_perm( Device.CHANGE_PERMISSION, self.group1, self.qemu_device_type )
def test_assign_perm_not_persisted(self): device = Device() with TestCase.assertRaises(self, ObjectNotPersisted): GroupDevicePermission.objects.assign_perm( "change_device", self.group1, device )
def test_has_perm_wrong_app_label(self): with TestCase.assertRaises(self, ValueError): self.backend.has_perm(self.user, "lava_results_app.change_device", self.device)