def _create_nested_executions(self, depth=2):
        """Utility function for easily creating nested LiveAction and ActionExecutions for testing

        returns (childmost_liveaction_db, parentmost_liveaction_db)
        """

        if depth <= 0:
            raise Exception("Please provide a depth > 0")

        root_liveaction_db = LiveActionDB()
        root_liveaction_db.status = action_constants.LIVEACTION_STATUS_PAUSED
        root_liveaction_db.action = ACTION_WORKFLOW_REF
        root_liveaction_db = LiveAction.add_or_update(root_liveaction_db)
        root_ex = executions.create_execution_object(root_liveaction_db)

        last_id = root_ex["id"]

        # Create children to the specified depth
        for i in range(depth):

            # Childmost liveaction should use ACTION_REF, everything else
            # should use ACTION_WORKFLOW_REF
            if i == depth:
                action = ACTION_REF
            else:
                action = ACTION_WORKFLOW_REF

            child_liveaction_db = LiveActionDB()
            child_liveaction_db.status = action_constants.LIVEACTION_STATUS_PAUSED
            child_liveaction_db.action = action
            child_liveaction_db.context = {"parent": {"execution_id": last_id}}
            child_liveaction_db = LiveAction.add_or_update(child_liveaction_db)
            parent_ex = executions.create_execution_object(child_liveaction_db)
            last_id = parent_ex.id

        # Return the last-created child as well as the root
        return (child_liveaction_db, root_liveaction_db)
Utility function for easily creating nested LiveAction and ActionExecutions for testing

        returns (childmost_liveaction_db, parentmost_liveaction_db)
        
st2common/tests/unit/services/test_action.py