Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
@uplink.get("repos/{user}/{repo}/issues/{issue}")
def get_issue(self, user, repo, issue):
pass
@uplink.get("/users/{user}")
def get_user(self, user):
pass
@uplink.get("/calendar/{todo_id}")
def get_todo(self, todo_id):
pass
@uplink.get("/users/{user}/repos")
def get_repos(self, user):
pass
@uplink.get("users/{user}")
def get_user(self, user):
pass
def argument_mock(mocker):
return mocker.Mock(spec=arguments.ArgumentAnnotation)
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"}
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)
def test_modify_request(self, request_builder):
arguments.Context("key").modify_request(request_builder, "value")
assert request_builder.context["key"] == "value"