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_modify_request_with_mismatched_encoding(self, request_builder):
arguments.Query("name", encoded=True).modify_request(
request_builder, "value"
)
with pytest.raises(arguments.Query.QueryStringEncodingError):
arguments.Query("name2", encoded=False).modify_request(
request_builder, "value2"
)
def test_skip_none(self, request_builder):
arguments.Query("name").modify_request(request_builder, None)
assert request_builder.info["params"] == {}
def test_modify_request_with_mismatched_encoding(self, request_builder):
arguments.Query("name", encoded=True).modify_request(
request_builder, "value"
)
with pytest.raises(arguments.Query.QueryStringEncodingError):
arguments.Query("name2", encoded=False).modify_request(
request_builder, "value2"
)
def test_modify_request_with_encoded(self, request_builder):
arguments.Query("name", encoded=True).modify_request(
request_builder, "value"
)
assert request_builder.info["params"] == "name=value"
def test_modify_request(self, request_builder):
arguments.Query("name").modify_request(request_builder, "value")
assert request_builder.info["params"] == {"name": "value"}
def test_converter_key_with_encoded(self):
query = arguments.Query("name", encoded=True)
assert query.converter_key == keys.CONVERT_TO_STRING
def test_converter_type(self):
query = arguments.Query("name", encoded=False)
assert query.converter_key == keys.Sequence(keys.CONVERT_TO_STRING)
def update_params(info, new_params, encoded):
existing = info.setdefault("params", None if encoded else dict())
if encoded == isinstance(existing, collections.Mapping):
raise Query.QueryStringEncodingError()
Query._update_params(info, existing, new_params, encoded)
def _modify_request(self, request_builder, value):
"""Updates request body with the mapping of query args."""
Query.update_params(request_builder.info, value, self._encoded)