Esempio n. 1
0
def test_fetch(mocker, session, site):
    status = mocker.patch('solarforecastarbiter.io.fetch.pvdaq.get_pvdaq_data')
    start = pd.Timestamp('2020-01-01T0000Z')
    end = pd.Timestamp('2020-01-02T0000Z')
    api_key = 'nopethepope'
    pvdaq.fetch(session, site, start, end, nrel_pvdaq_api_key=api_key)
    assert status.called
Esempio n. 2
0
def test_fetch_fail_except(session, site, mocker, log):
    start = pd.Timestamp('2020-01-01T0000Z')
    end = pd.Timestamp('2020-01-02T0000Z')
    api_key = 'nopethepope'
    status = mocker.patch('solarforecastarbiter.io.fetch.pvdaq.get_pvdaq_data')
    status.side_effect = Exception
    out = pvdaq.fetch(session, site, start, end, nrel_pvdaq_api_key=api_key)
    assert log.warning.call_count == 1
    assert out.empty
Esempio n. 3
0
def test_fetch_fail(session, site_no_extra):
    start = pd.Timestamp('2020-01-01T0000Z')
    end = pd.Timestamp('2020-01-02T0000Z')
    api_key = 'nopethepope'
    out = pvdaq.fetch(session,
                      site_no_extra,
                      start,
                      end,
                      nrel_pvdaq_api_key=api_key)
    assert out.empty
def test_fetch_fail_nonexistenttime(session, site, mocker, log):
    site = site.replace(timezone='America/Denver')
    start = pd.Timestamp('2020-01-01T0000Z')
    end = pd.Timestamp('2020-01-02T0000Z')
    api_key = 'nopethepope'
    index = pd.DatetimeIndex(['2020-03-08 02:00:00'])
    df = pd.DataFrame({'ac_power': 0}, index=index)
    patch = mocker.patch('solarforecastarbiter.io.fetch.pvdaq.get_pvdaq_data')
    patch.return_value = df
    out = pvdaq.fetch(session, site, start, end, nrel_pvdaq_api_key=api_key)
    assert log.warning.call_count == 1
    assert out.empty