def test_action_instance_cancels_current_running_clients( self, workflow_engine, db_session, get_action_instance, store_service): """ @rapid-unit Workflow:Cancel Action Instance:Should cancel active client :param db_session: :type db_session: :param get_action_instance: :type get_action_instance: :param store_service: :type store_service: :return: :rtype: """ db_session.return_value = [Mock()] mock_workflow = Mock() workflow_engine.return_value = mock_workflow get_action_instance.return_value = Mock( assigned_to='12345', status_id=StatusConstants.INPROGRESS) setattr(get_action_instance, 'id', '54321') mock_constants = Mock() action_dal = ActionDal(flask_app=Mock(), queue_constants=mock_constants) eq_("Action Instance has been canceled.", action_dal.cancel_action_instance(123455)['message']) mock_workflow.complete_an_action.assert_called_with( 123455, StatusConstants.CANCELED) mock_constants.cancel_worker.assert_called_with( get_action_instance().serialize())
def test_action_instance_returns_404_when_not_found( self, db_session, get_action_instance): """ @rapid-unit Workflow:Cancel Action Instance:Should return a 404 if not found :return: :rtype: """ db_session.return_value = [Mock()] get_action_instance.return_value = None action_dal = ActionDal(flask_app=Mock()) with self.assertRaises(InvalidObjectException) as exception: action_dal.cancel_action_instance(12345) eq_(404, exception.exception.code) eq_("Action Instance not found", exception.exception.description)