How to use uplink - 10 common examples

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-protobuf / tests / test_converter.py View on Github external
def test_create_response_body_converter__returns_json(
    mocker, message_mock, request_definition_mock
):
    # Setup
    json_response = {"hello": "world"}
    request_definition_mock.method_annotations = (returns.json(),)
    ParseDict = mocker.patch("google.protobuf.json_format.ParseDict")

    # Run
    run_create_response_body_converter_test(
        mocker, message_mock, request_definition_mock, json_response
    )

    # Verify
    ParseDict.assert_called_with(json_response, message_mock)
github prkumar / uplink / tests / integration / test_ratelimit.py View on Github external
    @uplink.get("repos/{user}/{repo}/issues/{issue}")
    def get_issue(self, user, repo, issue):
        pass
github prkumar / uplink / tests / integration / test_returns.py View on Github external
    @uplink.get("/users/{user}")
    def get_user(self, user):
        pass
github prkumar / uplink / tests / integration / test_handlers.py View on Github external
    @uplink.get("/calendar/{todo_id}")
    def get_todo(self, todo_id):
        pass
github prkumar / uplink / tests / integration / test_returns.py View on Github external
    @uplink.get("/users/{user}/repos")
    def get_repos(self, user):
        pass
github prkumar / uplink / tests / integration / test_ratelimit.py View on Github external
    @uplink.get("users/{user}")
    def get_user(self, user):
        pass
github prkumar / uplink / tests / unit / test_arguments.py View on Github external
def argument_mock(mocker):
    return mocker.Mock(spec=arguments.ArgumentAnnotation)
github prkumar / uplink / tests / unit / test_arguments.py View on Github external
request_builder.info["data"] = object()
        with pytest.raises(arguments.FieldMap.FieldMapUpdateFailed):
            arguments.FieldMap().modify_request(request_builder, {})


class TestPart(ArgumentTestCase):
    type_cls = arguments.Part
    expected_converter_key = keys.CONVERT_TO_REQUEST_BODY

    def test_modify_request(self, request_builder):
        arguments.Part("hello").modify_request(request_builder, "world")
        assert request_builder.info["files"] == {"hello": "world"}


class TestPartMap(ArgumentTestCase):
    type_cls = arguments.PartMap
    expected_converter_key = keys.Map(TestPart.expected_converter_key)

    def test_modify_request(self, request_builder):
        arguments.PartMap().modify_request(request_builder, {"hello": "world"})
        assert request_builder.info["files"] == {"hello": "world"}


class TestBody(ArgumentTestCase):
    type_cls = arguments.Body
    expected_converter_key = keys.CONVERT_TO_REQUEST_BODY

    def test_modify_request(self, request_builder):
        # Verify with dict
        arguments.Body().modify_request(request_builder, {"hello": "world"})
        assert request_builder.info["data"] == {"hello": "world"}
github prkumar / uplink / tests / unit / test_arguments.py View on Github external
def test_add_annotation_with_no_missing_arguments(self, argument_mock):
        def dummy():
            pass

        builder = arguments.ArgumentAnnotationHandlerBuilder(dummy, [], False)
        with pytest.raises(arguments.ExhaustedArguments):
            builder.add_annotation(argument_mock)
github prkumar / uplink / tests / unit / test_arguments.py View on Github external
def test_modify_request(self, request_builder):
        arguments.Context("key").modify_request(request_builder, "value")
        assert request_builder.context["key"] == "value"