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"}
示例#2
0
class TestHeaderMap(ArgumentTestCase, FuncDecoratorTestCase):
    type_cls = types.HeaderMap
    expected_converter_key = keys.Map(TestHeader.expected_converter_key)

    def test_modify_request(self, request_builder):
        types.HeaderMap().modify_request(request_builder, {"hello": "world"})
        assert request_builder.info["headers"] == {"hello": "world"}
示例#3
0
class TestFieldMap(ArgumentTestCase):
    type_cls = types.FieldMap
    expected_converter_key = keys.Map(TestField.expected_converter_key)

    def test_modify_request(self, request_builder):
        types.FieldMap().modify_request(request_builder, {"hello": "world"})
        assert request_builder.info["data"] == {"hello": "world"}

    def test_modify_request_failure(self, request_builder):
        request_builder.info["data"] = object()
        with pytest.raises(types.FieldMap.FieldMapUpdateFailed):
            types.FieldMap().modify_request(request_builder, {})
示例#4
0
class TestQueryMap(ArgumentTestCase):
    type_cls = types.QueryMap
    expected_converter_key = keys.Map(TestQuery.expected_converter_key)

    def test_modify_request(self, request_builder):
        types.QueryMap().modify_request(request_builder, {"hello": "world"})
        assert request_builder.info["params"] == {"hello": "world"}

    def test_modify_request_with_encoded(self, request_builder):
        types.QueryMap(encoded=True).modify_request(request_builder,
                                                    {"name": "value"})
        assert request_builder.info["params"] == "name=value"
示例#5
0
class TestQueryMap(ArgumentTestCase, FuncDecoratorTestCase):
    type_cls = types.QueryMap
    expected_converter_key = keys.Map(TestQuery.expected_converter_key)

    def test_modify_request(self, request_builder):
        types.QueryMap().modify_request(request_builder, {"hello": "world"})
        assert request_builder.info["params"] == {"hello": "world"}

    def test_modify_request_with_encoded(self, request_builder):
        types.QueryMap(encoded=True).modify_request(request_builder,
                                                    {"name": "value"})
        assert request_builder.info["params"] == "name=value"

    def test_converter_key_with_encoded(self):
        query = types.QueryMap(encoded=True)
        assert query.converter_key == keys.Map(keys.CONVERT_TO_STRING)

    def test_converter_type(self):
        query = types.QueryMap(encoded=False)
        assert query.converter_key == keys.Map(
            keys.Sequence(keys.CONVERT_TO_STRING))
 def test_converter_type(self):
     query = arguments.QueryMap(encoded=False)
     assert query.converter_key == keys.Map(
         keys.Sequence(keys.CONVERT_TO_STRING))
 def test_converter_key_with_encoded(self):
     query = arguments.QueryMap(encoded=True)
     assert query.converter_key == keys.Map(keys.CONVERT_TO_STRING)
 def converter_key(self):
     """Converts each part to the request body."""
     return keys.Map(keys.CONVERT_TO_REQUEST_BODY)
 def converter_key(self):
     """Converts type to request body."""
     return keys.Map(keys.CONVERT_TO_REQUEST_BODY)
示例#10
0
 def converter_key(self):
     """Converts every header field to string"""
     return keys.Map(keys.CONVERT_TO_STRING)
示例#11
0
 def converter_key(self):
     """Converts query mapping to request body."""
     if self._encoded:
         return keys.Map(keys.CONVERT_TO_STRING)
     else:
         return keys.Map(keys.Sequence(keys.CONVERT_TO_STRING))
示例#12
0
文件: types.py 项目: ppslim/uplink
 def converter_key(self):
     """Converts type to string."""
     return keys.Map(keys.CONVERT_TO_STRING)