def test_permission_allowed_correctly(self, action_allowed): func = permission_required([('Admin', '%')])(self.f) func(self.request) action_allowed.assert_called_with(self.request, 'Admin', '%')
def test_permission_allowed(self, action_allowed): action_allowed.return_value = True func = permission_required([('', '')])(self.f) func(self.request) assert self.f.called
def test_permission_not_allowed(self, action_allowed): action_allowed.return_value = False func = permission_required([('', '')])(self.f) with self.assertRaises(PermissionDenied): func(self.request)