예제 #1
0
 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)
예제 #2
0
    def test_devicetype_manager_accessible_wrong_permission(self):

        with TestCase.assertRaises(self, ValueError):
            DeviceType.objects.all().accessible_by_user(self.user1, "non_existing_perm")
예제 #3
0
 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
         )
예제 #4
0
 def test_assign_perm_not_persisted(self):
     device = Device()
     with TestCase.assertRaises(self, ObjectNotPersisted):
         GroupDevicePermission.objects.assign_perm(
             "change_device", self.group1, device
         )
예제 #5
0
 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)