Beispiel #1
0
def test_missing_metadata():
    attributes = grdc_metadata_reader(os.path.join(grdc_data, "30.day"))
    assert attributes["file_generation_date"] == "NA"
    assert attributes["river_name"] == "NA"
    assert attributes["station_name"] == "NA"
    assert attributes["country_code"] == "NA"
    assert attributes["grdc_latitude_in_arc_degree"] == "NA"
    assert attributes["grdc_longitude_in_arc_degree"] == "NA"
    assert attributes["grdc_catchment_area_in_km2"] == "NA"
    assert attributes["altitude_masl"] == "NA"
    assert attributes["dataSetContent"] == "NA"
    assert attributes["units"] == "NA"
    assert attributes["time_series"] == "NA"
    assert attributes["no_of_years"] == "NA"
    assert attributes["last_update"] == "NA"
    assert attributes["nrMeasurements"] == "NA"
Beispiel #2
0
def test_grdc_metadata():
    grdc_data_file = os.path.join(grdc_data, "146.day")
    attributes = grdc_metadata_reader(grdc_data_file)
    assert attributes["grdc_file_name"] == grdc_data_file
    assert attributes["id_from_grdc"] == 146
    assert attributes["file_generation_date"] == "2019-01-22"
    assert attributes["river_name"] == "THAMES"
    assert attributes["station_name"] == "TOWER_BRIDGE"
    assert attributes["country_code"] == "UK"
    assert attributes["grdc_latitude_in_arc_degree"] == 51.5055
    assert attributes["grdc_longitude_in_arc_degree"] == 0.0754
    assert attributes["grdc_catchment_area_in_km2"] == 1.11
    assert attributes["altitude_masl"] == 2.2
    assert attributes["dataSetContent"] == "MADE UP TEST DATA"
    assert attributes["units"] == "pounds per square inch"
    assert attributes["time_series"] == "1967 until yesterday"
    assert attributes["no_of_years"] == 52
    assert attributes["last_update"] == "2019-01-22"
    assert attributes["nrMeasurements"] == 30
Beispiel #3
0
def test_negative_catchment():
    attributes = grdc_metadata_reader(os.path.join(grdc_data, "40.day"))
    assert attributes["grdc_catchment_area_in_km2"] == "NA"
Beispiel #4
0
def test_inconsistent_metadata():
    attributes = grdc_metadata_reader(os.path.join(grdc_data, "10.day"))
    assert len(attributes) == 0
Beispiel #5
0
def test_no_metadata():
    with pytest.raises(Exception):
        grdc_metadata_reader(os.path.join(grdc_data, "666.day"))