How to use the uplink.commands.RequestDefinitionBuilder function in uplink

To help you get started, we’ve selected a few uplink examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github prkumar / uplink / tests / unit / test_commands.py View on Github external
def test_method_handler_builder_getter(
        self, annotation_handler_builder_mock
    ):
        builder = commands.RequestDefinitionBuilder(
            None,
            None,
            type(annotation_handler_builder_mock)(),
            annotation_handler_builder_mock,
        )
        assert builder.method_handler_builder is annotation_handler_builder_mock
github prkumar / uplink / tests / unit / test_commands.py View on Github external
def test_auto_fill_when_not_done(
        self, mocker, annotation_handler_builder_mock
    ):
        # Setup
        argument_handler_builder = mocker.Mock(
            stub=arguments.ArgumentAnnotationHandlerBuilder
        )
        method_handler_builder = annotation_handler_builder_mock
        uri_definition_builder = mocker.Mock(spec=commands.URIDefinitionBuilder)
        builder = commands.RequestDefinitionBuilder(
            "method",
            uri_definition_builder,
            argument_handler_builder,
            method_handler_builder,
        )

        # Setup success condition
        argument_handler_builder.is_done.return_value = False
        argument_handler_builder.missing_arguments = ["arg1"]
        uri_definition_builder.remaining_variables = ["arg1"]

        # Verify
        builder.build()
        argument_handler_builder.set_annotations.assert_called_with(
            {"arg1": arguments.Path}
        )
github prkumar / uplink / tests / unit / test_commands.py View on Github external
def test_auto_fill_when_not_done(
        self, mocker, annotation_handler_builder_mock
    ):
        # Setup
        argument_handler_builder = mocker.Mock(
            stub=arguments.ArgumentAnnotationHandlerBuilder
        )
        method_handler_builder = annotation_handler_builder_mock
        uri_definition_builder = mocker.Mock(spec=commands.URIDefinitionBuilder)
        builder = commands.RequestDefinitionBuilder(
            "method",
            uri_definition_builder,
            argument_handler_builder,
            method_handler_builder,
        )

        # Setup success condition
        argument_handler_builder.is_done.return_value = False
        argument_handler_builder.missing_arguments = ["arg1"]
        uri_definition_builder.remaining_variables = ["arg1"]

        # Verify
        builder.build()
        argument_handler_builder.set_annotations.assert_called_with(
            {"arg1": arguments.Path}
        )
github prkumar / uplink / tests / unit / test_commands.py View on Github external
def test_auto_fill_when_not_done_fails(
        self, mocker, annotation_handler_builder_mock
    ):
        # Setup
        argument_handler_builder = annotation_handler_builder_mock
        method_handler_builder = annotation_handler_builder_mock
        uri_definition_builder = mocker.Mock(spec=commands.URIDefinitionBuilder)
        builder = commands.RequestDefinitionBuilder(
            "method",
            uri_definition_builder,
            argument_handler_builder,
            method_handler_builder,
        )

        # Setup fail condition: Argument is missing annotation
        argument_handler_builder.is_done.return_value = False
        argument_handler_builder.missing_arguments = ["arg1"]
        uri_definition_builder.remaining_variables = []

        # Verify
        with pytest.raises(commands.MissingArgumentAnnotations):
            builder.build()
github prkumar / uplink / tests / unit / test_commands.py View on Github external
def test_auto_fill_when_not_done_fails(
        self, mocker, annotation_handler_builder_mock
    ):
        # Setup
        argument_handler_builder = annotation_handler_builder_mock
        method_handler_builder = annotation_handler_builder_mock
        uri_definition_builder = mocker.Mock(spec=commands.URIDefinitionBuilder)
        builder = commands.RequestDefinitionBuilder(
            "method",
            uri_definition_builder,
            argument_handler_builder,
            method_handler_builder,
        )

        # Setup fail condition: Argument is missing annotation
        argument_handler_builder.is_done.return_value = False
        argument_handler_builder.missing_arguments = ["arg1"]
        uri_definition_builder.remaining_variables = []

        # Verify
        with pytest.raises(commands.MissingArgumentAnnotations):
            builder.build()
github prkumar / uplink / tests / unit / test_commands.py View on Github external
def test_method_handler_builder_getter(
        self, annotation_handler_builder_mock
    ):
        builder = commands.RequestDefinitionBuilder(
            None,
            None,
            type(annotation_handler_builder_mock)(),
            annotation_handler_builder_mock,
        )
        assert builder.method_handler_builder is annotation_handler_builder_mock
github prkumar / uplink / tests / unit / test_commands.py View on Github external
def test_build(self, mocker, annotation_handler_builder_mock):
        argument_handler_builder = type(annotation_handler_builder_mock)()
        method_handler_builder = annotation_handler_builder_mock
        uri_definition_builder = mocker.Mock(spec=commands.URIDefinitionBuilder)
        builder = commands.RequestDefinitionBuilder(
            "method",
            uri_definition_builder,
            argument_handler_builder,
            method_handler_builder,
        )
        definition = builder.build()
        assert isinstance(definition, commands.RequestDefinition)
        assert uri_definition_builder.build.called
        assert argument_handler_builder.build.called
        assert method_handler_builder.build.called
github prkumar / uplink / tests / unit / test_commands.py View on Github external
def test_build(self, mocker, annotation_handler_builder_mock):
        argument_handler_builder = type(annotation_handler_builder_mock)()
        method_handler_builder = annotation_handler_builder_mock
        uri_definition_builder = mocker.Mock(spec=commands.URIDefinitionBuilder)
        builder = commands.RequestDefinitionBuilder(
            "method",
            uri_definition_builder,
            argument_handler_builder,
            method_handler_builder,
        )
        definition = builder.build()
        assert isinstance(definition, commands.RequestDefinition)
        assert uri_definition_builder.build.called
        assert argument_handler_builder.build.called
        assert method_handler_builder.build.called
github prkumar / uplink / uplink / commands.py View on Github external
def _extend(self, method, uri, arg_handler, _):
        builder = RequestDefinitionBuilder(
            method, uri, arg_handler, self.method_handler_builder.copy()
        )
        builder.return_type = self.return_type
        return builder
github prkumar / uplink / uplink / commands.py View on Github external
def copy(self):
        builder = RequestDefinitionBuilder(
            self._method,
            self._uri,
            self._argument_handler_builder.copy(),
            self._method_handler_builder.copy(),
        )
        builder.return_type = self.return_type
        return builder