Exemplo n.º 1
0
def test_codes_get(key, expected_type, expected_value):
    grib = eccodes.codes_handle_new_from_file(open(TEST_DATA))

    result = eccodes.codes_get(grib, key)

    assert isinstance(result, expected_type)
    assert result == expected_value
Exemplo n.º 2
0
def test_codes_index_select(key, value):
    grib_index = eccodes.codes_index_new_from_file(TEST_DATA_B, [key])

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

    result = eccodes.codes_get(grib_handle, key)

    assert result == value
Exemplo n.º 3
0
def test_codes_get_errors():
    grib = eccodes.codes_handle_new_from_file(open(TEST_DATA))

    with pytest.raises(eccodes.EcCodesError) as err:
        eccodes.codes_get(grib, b'gridType', length=1)  # too short
    assert err.value.code == eccodes.lib.GRIB_BUFFER_TOO_SMALL