diff --git a/src/database.py b/src/database.py index 00be6e4b..fd25561a 100644 --- a/src/database.py +++ b/src/database.py @@ -171,7 +171,6 @@ def get_latest_forecast_values_for_a_specific_gsp_from_database( start_datetime = get_start_datetime() if forecast_horizon_minutes is None: - forecast_values = get_forecast_values_latest( session=session, gsp_id=gsp_id, start_datetime=start_datetime, model_name="blend" ) @@ -187,9 +186,11 @@ def get_latest_forecast_values_for_a_specific_gsp_from_database( ) # convert to pydantic objects - if isinstance(forecast_values[0], ForecastValueSevenDaysSQL) or \ - isinstance(forecast_values[0], ForecastValueSQL) or \ - isinstance(forecast_values[0], ForecastValueLatestSQL): + if ( + isinstance(forecast_values[0], ForecastValueSevenDaysSQL) + or isinstance(forecast_values[0], ForecastValueSQL) + or isinstance(forecast_values[0], ForecastValueLatestSQL) + ): forecast_values = [ForecastValue.from_orm(f) for f in forecast_values] return forecast_values @@ -243,7 +244,10 @@ def get_truth_values_for_a_specific_gsp_from_database( def get_truth_values_for_all_gsps_from_database( - session: Session, start_gsp: Optional[int] = 1, end_gsp: Optional[int] = N_GSP+1, regime: Optional[str] = "in-day" + session: Session, + start_gsp: Optional[int] = 1, + end_gsp: Optional[int] = N_GSP + 1, + regime: Optional[str] = "in-day", ) -> List[LocationWithGSPYields]: """Get the truth value for all gsps for yesterday and today diff --git a/src/tests/test_gsp.py b/src/tests/test_gsp.py index deb7b23c..f597966c 100644 --- a/src/tests/test_gsp.py +++ b/src/tests/test_gsp.py @@ -22,7 +22,9 @@ def test_read_latest_one_gsp(db_session, api_client): """Check main solar/GB/gsp/{gsp_id}/forecast route works""" - forecasts = make_fake_forecasts(gsp_ids=list(range(0, 2)), session=db_session, add_latest=True, model_name='blend') + forecasts = make_fake_forecasts( + gsp_ids=list(range(0, 2)), session=db_session, add_latest=True, model_name="blend" + ) db_session.add_all(forecasts) db_session.commit() @@ -72,7 +74,9 @@ def test_read_latest_gsp_id_greater_than_total(db_session, api_client): def test_read_latest_gsp_id_equal_to_total(db_session, api_client): """Check that request with gsp_id<318 returns 200""" - forecasts = make_fake_forecasts(gsp_ids=[317], session=db_session, add_latest=True, model_name='blend') + forecasts = make_fake_forecasts( + gsp_ids=[317], session=db_session, add_latest=True, model_name="blend" + ) db_session.add_all(forecasts) app.dependency_overrides[get_session] = lambda: db_session diff --git a/src/tests/test_merged_routes.py b/src/tests/test_merged_routes.py index 3781c17b..583b55a2 100644 --- a/src/tests/test_merged_routes.py +++ b/src/tests/test_merged_routes.py @@ -17,19 +17,28 @@ def test_read_forecast_values_gsp(db_session, api_client): model = get_model(session=db_session, name="blend", version="0.0.1") forecast_value_1_sql = ForecastValueLatestSQL( - target_time=datetime(2023, 6, 2), expected_power_generation_megawatts=1, gsp_id=1, model_id=model.id + target_time=datetime(2023, 6, 2), + expected_power_generation_megawatts=1, + gsp_id=1, + model_id=model.id, ) forecast_value_2_sql = ForecastValueLatestSQL( - target_time=datetime(2023, 6, 1, 1), expected_power_generation_megawatts=2, gsp_id=1, model_id=model.id + target_time=datetime(2023, 6, 1, 1), + expected_power_generation_megawatts=2, + gsp_id=1, + model_id=model.id, ) forecast_value_3_sql = ForecastValueLatestSQL( - target_time=datetime(2023, 6, 1), expected_power_generation_megawatts=3, gsp_id=1, model_id=model.id + target_time=datetime(2023, 6, 1), + expected_power_generation_megawatts=3, + gsp_id=1, + model_id=model.id, ) forecast = make_fake_forecast( - gsp_id=1, session=db_session, t0_datetime_utc=datetime(2023, 1, 1), model_name='blend' + gsp_id=1, session=db_session, t0_datetime_utc=datetime(2023, 1, 1), model_name="blend" ) forecast.forecast_values_latest.append(forecast_value_1_sql) forecast.forecast_values_latest.append(forecast_value_2_sql)