Example #1
0
    def __init__(self, method, uri=None, args=None):
        self._method = method
        self._uri = uri

        # Register argument annotations
        if args:
            is_map = isinstance(args, collections.Mapping)
            args, kwargs = ((), args) if is_map else (args, {})
            self._add_args = decorators.args(*args, **kwargs)
Example #2
0
def test_args_decorate_function(mocker):
    handler = mocker.Mock(spec=["set_annotations"])

    @classmethod
    def patched(*_):
        return handler

    mocker.patch("uplink.arguments.ArgumentAnnotationHandlerBuilder.from_func",
                 patched)
    args = decorators.args(str, str, name=str)
    func = mocker.stub()
    args(func)
    handler.set_annotations.assert_called_with((str, str), name=str)
Example #3
0
def test_args(request_definition_builder):
    args = decorators.args(str, str, name=str)
    args.modify_request_definition(request_definition_builder)
    builder = request_definition_builder.argument_handler_builder
    builder.set_annotations.assert_called_with((str, str), name=str)
Example #4
0
def test_args_call_old(request_definition_builder):
    annotation = decorators.args(str, str, name=str)
    annotation(request_definition_builder)
    handler = request_definition_builder.method_handler_builder
    handler.add_annotation.assert_called_with(annotation)