示例#1
0
def test_codes_get(key, expected_type, expected_value):
    grib = bindings.codes_handle_new_from_file(open(TEST_DATA))

    result = bindings.codes_get(grib, key)

    assert isinstance(result, expected_type)
    assert result == expected_value
示例#2
0
def test_codes_index_select(key, value):
    grib_index = bindings.codes_index_new_from_file(TEST_DATA_B, [key])

    bindings.codes_index_select(grib_index, key, value)
    grib_handle = bindings.codes_new_from_index(grib_index)

    result = bindings.codes_get(grib_handle, key)

    assert result == value
示例#3
0
def test_codes_get_errors():
    grib = bindings.codes_handle_new_from_file(open(TEST_DATA))

    with pytest.raises(bindings.EcCodesError) as err:
        bindings.codes_get(grib, b'gridType', length=1)  # too short
    assert err.value.code == bindings.lib.GRIB_BUFFER_TOO_SMALL
示例#4
0
def test_codes_get_errors():
    grib = bindings.codes_grib_new_from_file(open(TEST_DATA))

    with pytest.raises(bindings.GribInternalError) as err:
        bindings.codes_get(grib, "gridType", length=1)  # too short
    assert err.value.code == bindings.lib.GRIB_BUFFER_TOO_SMALL