Source code for gridstatus.tests.test_eia

import pandas as pd

import gridstatus


def _check_interchange(df):
    columns = [
        "Interval Start",
        "Interval End",
        "From BA",
        "From BA Name",
        "To BA",
        "To BA Name",
        "MW",
    ]
    # assert interval start and interval end are datetimes in utc
    assert df["Interval Start"].dtype == "datetime64[ns, UTC]"
    assert df["Interval End"].dtype == "datetime64[ns, UTC]"
    assert df.shape[0] > 0
    assert df.columns.tolist() == columns


[docs]def test_rto_interchange(): eia = gridstatus.EIA() start = "2020-01-01" end = "2020-01-04" df = eia.get_dataset( dataset="electricity/rto/interchange-data", start=start, end=end, verbose=True, ) assert df["Interval End"].min().date() == pd.Timestamp(start).date() assert df["Interval End"].max().date() == pd.Timestamp(end).date() _check_interchange(df)
[docs]def test_list_routes(): eia = gridstatus.EIA() routes = eia.list_routes("electricity/rto/") assert "interchange-data" in [r["id"] for r in routes["routes"]]
[docs]def test_other_dataset(): eia = gridstatus.EIA() start = "2020-01-01" end = "2020-01-04" # dataset that doesnt have a handler yet df = eia.get_dataset( dataset="electricity/rto/fuel-type-data", start=start, end=end, verbose=True, ) cols = [ "period", "respondent", "respondent-name", "fueltype", "type-name", "value", "value-units", ] assert df.columns.tolist() == cols assert df.shape[0] > 0