Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdudfield committed Sep 27, 2023
1 parent c0cdfe8 commit 3e67a1f
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/tests/test_national.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,35 @@ def test_read_latest_national_values_no_properties(db_session, api_client):
)


def test_read_latest_national_values_properties(db_session, api_client):
"""Check main solar/GB/national/forecast route works
Check fake propreties are made
"""

model = get_model(db_session, name="blend", version="0.0.1")

forecast = make_fake_national_forecast(
session=db_session, t0_datetime_utc=datetime.now(tz=timezone.utc)
)
forecast.model = model

db_session.add(forecast)
update_all_forecast_latest(forecasts=[forecast], session=db_session)

app.dependency_overrides[get_session] = lambda: db_session

response = api_client.get("/v0/solar/GB/national/forecast")
assert response.status_code == 200

national_forecast_values = [NationalForecastValue(**f) for f in response.json()]
assert national_forecast_values[0].plevels is not None
# index 24 is the middle of the day
assert np.round(national_forecast_values[24].plevels["plevel_10"], 2) == np.round(
national_forecast_values[24].expected_power_generation_megawatts * 0.9, 2
)


@freeze_time("2022-01-01")
def test_read_truth_national_gsp(db_session, api_client):
"""Check main solar/GB/national/pvlive route works"""
Expand Down

0 comments on commit 3e67a1f

Please sign in to comment.