示例#1
0
def test_output_fn_csv(np_array):
    response = serving.default_output_fn(np_array, content_types.CSV)

    assert response.get_data(as_text=True) == '1.0,1.0\n1.0,1.0\n'
    # TODO This is a workaround to get the test passsing.
    # Not sure if it is related to executing tests on Mac in specific virtual environment,
    # but the content type in response is: 'text/csv; charset=utf-8' instead of the expected: text/csv
    assert content_types.CSV in response.content_type
def test_input_fn_bad_accept():
    with pytest.raises(errors.UnsupportedFormatError):
        serving.default_output_fn('', 'application/not_supported')
def test_output_fn_npz(np_array):
    response = serving.default_output_fn(np_array, content_types.NPY)

    assert response.get_data() == encoders.array_to_npy(np_array)
    assert response.content_type == content_types.NPY
def test_output_fn_json(np_array):
    response = serving.default_output_fn(np_array, content_types.JSON)

    assert response.get_data(as_text=True) == encoders.array_to_json(
        np_array.tolist())
    assert response.content_type == content_types.JSON