예제 #1
0
def test_create_nwp_forecasts_outside(template_fx, mocker, log):
    vars_ = ('ac_power', 'dni')
    api, template, site = template_fx
    site = site.replace(latitude=19, longitude=-159)
    templates = [template.replace(name='one'), template.replace(name='two')]
    with pytest.raises(ValueError):
        common.create_nwp_forecasts(api, site, vars_, templates)
예제 #2
0
def test_create_nwp_forecasts(template_fx, mocker, vars_, primary):
    api, template, site = template_fx
    templates = [template.replace(name='one'), template.replace(name='two')]
    fxdict = template.to_dict()
    fxdict['constant_values'] = [0, 50, 100]
    fxdict['axis'] = 'y'
    templates += [ProbabilisticForecast.from_dict(fxdict)]

    fxs = common.create_nwp_forecasts(api, site, vars_, templates)
    assert len(fxs) == 6
    if primary:
        assert fxs[0].variable == primary
        assert fxs[2].variable == primary
    assert 'one' in fxs[0].name
    assert 'one' in fxs[1].name
    assert fxs[0].forecast_id in fxs[1].extra_parameters
    assert 'two' in fxs[2].name
    assert 'two' in fxs[3].name
    assert fxs[2].forecast_id in fxs[3].extra_parameters
    assert isinstance(fxs[-1], ProbabilisticForecast)