Esempio n. 1
0
def test_formats(empty_swagger_spec, array_spec):
    for fmt, sep in COLLECTION_FORMATS.items():
        array_spec['collectionFormat'] = fmt
        param_value = sep.join(['1', '2', '3'])
        assert [1, 2,
                3] == unmarshal_collection_format(empty_swagger_spec,
                                                  array_spec, param_value)
Esempio n. 2
0
def test_formats(empty_swagger_spec, param_spec):
    for fmt, sep in COLLECTION_FORMATS.items():
        param_spec['collectionFormat'] = fmt
        result = marshal_collection_format(
            empty_swagger_spec,
            param_spec,
            [1, 2, 3],
        )
        assert sep.join(['1', '2', '3']) == result
Esempio n. 3
0
def test_ref(minimal_swagger_dict, array_spec):
    for fmt, sep in COLLECTION_FORMATS.items():
        array_spec['collectionFormat'] = fmt
        minimal_swagger_dict['parameters'] = {'BizIdsParam': array_spec}
        ref_spec = {'$ref': '#/parameters/BizIdsParam'}
        swagger_spec = Spec(minimal_swagger_dict)

        param_value = sep.join(['1', '2', '3'])
        assert [1, 2,
                3] == unmarshal_collection_format(swagger_spec, ref_spec,
                                                  param_value)
def test_ref(minimal_swagger_dict, array_spec):
    for fmt, sep in COLLECTION_FORMATS.items():
        array_spec['collectionFormat'] = fmt
        minimal_swagger_dict['parameters'] = {
            'BizIdsParam': array_spec
        }
        ref_spec = {'$ref': '#/parameters/BizIdsParam'}
        swagger_spec = Spec(minimal_swagger_dict)

        param_value = sep.join(['1', '2', '3'])
        assert [1, 2, 3] == unmarshal_collection_format(
            swagger_spec, ref_spec, param_value)
def test_formats(empty_swagger_spec, array_spec):
    for fmt, sep in COLLECTION_FORMATS.items():
        array_spec['collectionFormat'] = fmt
        param_value = sep.join(['1', '2', '3'])
        assert [1, 2, 3] == unmarshal_collection_format(
            empty_swagger_spec, array_spec, param_value)
Esempio n. 6
0
        '1,2,3',
    )


def test_formats(empty_swagger_spec, array_spec):
    for fmt, sep in COLLECTION_FORMATS.items():
        array_spec['collectionFormat'] = fmt
        param_value = sep.join(['1', '2', '3'])
        assert [1, 2, 3] == unmarshal_collection_format(
            empty_swagger_spec,
            array_spec,
            param_value,
        )


@pytest.mark.parametrize('format_name,separator', COLLECTION_FORMATS.items())
def test_formats_empty_list(empty_swagger_spec, array_spec, format_name,
                            separator):
    array_spec['collectionFormat'] = format_name
    param_value = separator.join([])
    assert [] == unmarshal_collection_format(
        empty_swagger_spec,
        array_spec,
        param_value,
    )


def test_multi_no_op_because_handled_by_http_client_lib(
    empty_swagger_spec,
    array_spec,
):
def test_defaults_to_csv(empty_swagger_spec, array_spec):
    del array_spec['collectionFormat']
    assert [1, 2, 3] == unmarshal_collection_format(
        empty_swagger_spec, array_spec, '1,2,3')


def test_formats(empty_swagger_spec, array_spec):
    for fmt, sep in COLLECTION_FORMATS.items():
        array_spec['collectionFormat'] = fmt
        param_value = sep.join(['1', '2', '3'])
        assert [1, 2, 3] == unmarshal_collection_format(
            empty_swagger_spec, array_spec, param_value)


@pytest.mark.parametrize('format_name,separator', COLLECTION_FORMATS.items())
def test_formats_empty_list(empty_swagger_spec, array_spec, format_name, separator):
    array_spec['collectionFormat'] = format_name
    param_value = separator.join([])
    assert [] == unmarshal_collection_format(
        empty_swagger_spec,
        array_spec,
        param_value,
    )


def test_multi_no_op_because_handled_by_http_client_lib(empty_swagger_spec,
                                                        array_spec):
    array_spec['collectionFormat'] = 'multi'
    assert [1, 2, 3] == unmarshal_collection_format(
        empty_swagger_spec, array_spec, [1, 2, 3])
def test_formats(array_spec):
    for fmt, sep in COLLECTION_FORMATS.iteritems():
        array_spec['collectionFormat'] = fmt
        result = marshal_collection_format(array_spec, [1, 2, 3])
        assert sep.join(['1', '2', '3']) == result
def test_formats(empty_swagger_spec, param_spec):
    for fmt, sep in COLLECTION_FORMATS.items():
        param_spec['collectionFormat'] = fmt
        result = marshal_collection_format(empty_swagger_spec,
                                           param_spec, [1, 2, 3])
        assert sep.join(['1', '2', '3']) == result
Esempio n. 10
0
def test_formats(array_spec):
    for fmt, sep in COLLECTION_FORMATS.items():
        array_spec['collectionFormat'] = fmt
        result = marshal_collection_format(array_spec, [1, 2, 3])
        assert sep.join(['1', '2', '3']) == result