def test_approve_transition(self): ct = ExternalContentType.objects.get(pk=1501) field = Field.objects.get(pk=3501) ObjectService.register_object(ct.pk, 5001, field.pk) ObjectService.register_object(ct.pk, 5002, field.pk) # #################### # STATE 1 - STATE 2 # Only User1(2001) can approve and after his approve state must be changed to STATE 2 # ################### # Approved by user has no required permission for this transition middleware.get_user = MagicMock(return_value=User.objects.get(pk=2101)) obj = Object.objects.get(object_id=5001) try: TransitionService.approve_transition(ct.pk, 5001, field.pk, 2) self.fail('Exception was expected') except Exception, e: self.assertEqual(e.message, 'There is no available state for destination for the user.')
self.assertEqual(e.message, 'There is no available state for destination for the user.') obj = Object.objects.get(object_id=5001) try: TransitionService.approve_transition(ct.pk, 5001, field.pk, 2) self.fail('Exception was expected') except Exception, e: self.assertEqual(e.message, 'There is no available state for destination for the user.') # Approved by user has no required permission for this transition obj = Object.objects.get(object_id=5001) try: TransitionService.approve_transition(ct.pk, 5001, field.pk, 3) self.fail('Exception was expected') except Exception, e: self.assertEqual(e.message, 'There is no available state for destination for the user.') obj = Object.objects.get(object_id=5001) try: TransitionService.approve_transition(ct.pk, 5001, field.pk, 3) self.fail('Exception was expected') except Exception, e: self.assertEqual(e.message, 'There is no available state for destination for the user.') # Approved by user has no required permission for this transition obj = Object.objects.get(object_id=5001)
def reject_transition(request, content_type_id, object_id, field_id, user_id, next_state_id=None): return TransitionService.reject_transition(content_type_id, object_id, field_id, user_id, next_state_id)