async def test_from_header_binding_name_ci(expected_type, header_value, expected_value):
    request = Request("GET", b"/", [(b"X-Foo", header_value)])

    parameter = HeaderBinder(expected_type, "x-foo")

    value = await parameter.get_value(request)

    assert isinstance(value, expected_type)
    assert value == expected_value
Exemple #2
0
async def test_from_header_binding_iterables(declared_type, expected_type,
                                             header_values, expected_values):
    request = Request("GET", b"/",
                      [(b"X-Foo", value) for value in header_values])

    parameter = HeaderBinder(declared_type, "X-Foo")

    value = await parameter.get_value(request)

    assert isinstance(value, expected_type)
    assert value == expected_values
Exemple #3
0
async def test_nested_iterables_raise_missing_converter_from_header(
        declared_type):
    with raises(MissingConverterError):
        HeaderBinder(declared_type)
Exemple #4
0
def test_sync_binders_source_name():
    assert CookieBinder().source_name == "cookie"
    assert HeaderBinder().source_name == "header"
    assert QueryBinder().source_name == "query"
    assert RouteBinder().source_name == "route"