示例#1
0
 def test_permission_allowed_correctly(self, action_allowed):
     func = decorators.permission_required('Admin', '%')(self.f)
     func(self.request)
     action_allowed.assert_called_with(self.request, 'Admin', '%')
示例#2
0
 def test_permission_not_allowed(self, action_allowed):
     action_allowed.return_value = False
     func = decorators.permission_required('', '')(self.f)
     with self.assertRaises(PermissionDenied):
         func(self.request)
示例#3
0
 def test_permission_allowed(self, action_allowed):
     action_allowed.return_value = True
     func = decorators.permission_required('', '')(self.f)
     func(self.request)
     assert self.f.called
示例#4
0
 def test_permission_allowed_correctly(self, action_allowed):
     func = decorators.permission_required('Admin', '%')(self.f)
     func(self.request)
     action_allowed.assert_called_with(self.request, 'Admin', '%')
示例#5
0
 def test_permission_allowed(self, action_allowed):
     action_allowed.return_value = True
     func = decorators.permission_required('', '')(self.f)
     func(self.request)
     assert self.f.called
示例#6
0
 def test_permission_not_allowed(self, action_allowed):
     action_allowed.return_value = False
     func = decorators.permission_required('', '')(self.f)
     with self.assertRaises(PermissionDenied):
         func(self.request)
示例#7
0
 def test_permission_not_allowed(self, action_allowed):
     action_allowed.return_value = False
     func = decorators.permission_required('', '')(self.f)
     eq_(func(self.request).status_code, 403)
示例#8
0
 def test_permission_not_allowed(self, action_allowed):
     action_allowed.return_value = False
     func = decorators.permission_required('', '')(self.f)
     eq_(func(self.request).status_code, 403)