Returns the method to be applied in place of an original method. This method either executes a side effect, returns an rvalue, or implements caching in place of the method_to_patch

    :param function method_to_patch: A reference to the method that will be patched.
    :param mixed side_effect: The side effect to execute. Either a callable with the same parameters as the target, or an exception.
    :param mixed rvalue: The value that should be immediately returned without executing the target.
    :param caliendo.Ignore ignore: The parameters that should be ignored when determining cachekeys. These are typically the dynamic values such as datetime.datetime.now() or a setting from an environment specific file.
    :param function callback: A pickleable callback to execute when the patched method is called and the cache is hit. (has to have been cached the first time).
    :param caliendo.hooks.Context ctxt: The context this patch should be executed under. Generally reserved for internal use. The vast majority of use cases should leave this parameter alone.
    :param mixed subsequent_rvalue: If passed; this will be the return value each time this method is run regardless of what is returned when it is initially cached. Caching for this method will be skipped. This is useful when the method returns something unpickleable but we still need to stub it out.

    :rtype: function
    :returns: The function to replace all references to method_to_patch with.

def get_replacement_method(method_to_patch, side_effect=UNDEFINED, rvalue=UNDEFINED, ignore=UNDEFINED, callback=UNDEFINED, context=UNDEFINED, subsequent_rvalue=UNDEFINED):
    """
    Returns the method to be applied in place of an original method. This method either executes a side effect, returns an rvalue, or implements caching in place of the method_to_patch

    :param function method_to_patch: A reference to the method that will be patched.
    :param mixed side_effect: The side effect to execute. Either a callable with the same parameters as the target, or an exception.
    :param mixed rvalue: The value that should be immediately returned without executing the target.
    :param caliendo.Ignore ignore: The parameters that should be ignored when determining cachekeys. These are typically the dynamic values such as datetime.datetime.now() or a setting from an environment specific file.
    :param function callback: A pickleable callback to execute when the patched method is called and the cache is hit. (has to have been cached the first time).
    :param caliendo.hooks.Context ctxt: The context this patch should be executed under. Generally reserved for internal use. The vast majority of use cases should leave this parameter alone.
    :param mixed subsequent_rvalue: If passed; this will be the return value each time this method is run regardless of what is returned when it is initially cached. Caching for this method will be skipped. This is useful when the method returns something unpickleable but we still need to stub it out.

    :rtype: function
    :returns: The function to replace all references to method_to_patch with.
    """
    def patch_with(*args, **kwargs):
        if side_effect != UNDEFINED:
            return execute_side_effect(side_effect, args, kwargs)
        if rvalue != UNDEFINED:
            return rvalue

        return cache(method_to_patch, args=args, kwargs=kwargs, ignore=ignore, call_stack=context.stack, callback=callback, subsequent_rvalue=subsequent_rvalue)
    return patch_with