diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 44e6da8b..37130e82 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,7 +1,7 @@ [bumpversion] commit = True tag = True -current_version = 1.5.25 +current_version = 1.5.27 message = Bump version: {current_version} → {new_version} [skip ci] [bumpversion:file:src/main.py] diff --git a/src/gsp.py b/src/gsp.py index 9d9497fe..663cc9c1 100644 --- a/src/gsp.py +++ b/src/gsp.py @@ -1,4 +1,5 @@ """Get GSP boundary data from eso """ +import os from typing import List, Optional, Union import structlog @@ -29,6 +30,7 @@ logger = structlog.stdlib.get_logger() +adjust_limit = float(os.getenv("ADJUST_MW_LIMIT", 0.0)) router = APIRouter() @@ -183,6 +185,11 @@ def get_forecasts_for_a_specific_gsp( creation_utc_limit=creation_limit_utc, ) + if gsp_id == 0: + forecast_values_for_specific_gsp = [ + f.adjust(limit=adjust_limit) for f in forecast_values_for_specific_gsp + ] + logger.debug("Got forecast values for a specific gsp.") return forecast_values_for_specific_gsp diff --git a/src/main.py b/src/main.py index e6ccca09..fa76f9f9 100644 --- a/src/main.py +++ b/src/main.py @@ -42,7 +42,7 @@ folder = os.path.dirname(os.path.abspath(__file__)) title = "Quartz Solar API" -version = "1.5.25" +version = "1.5.27" sentry_sdk.init( dsn=os.getenv("SENTRY_DSN"), diff --git a/src/tests/test_gsp.py b/src/tests/test_gsp.py index 57f38f7f..9a6b4111 100644 --- a/src/tests/test_gsp.py +++ b/src/tests/test_gsp.py @@ -40,6 +40,25 @@ def test_read_latest_one_gsp(db_session, api_client): _ = [ForecastValue(**f) for f in response.json()] +@freeze_time("2022-01-01") +def test_read_latest_one_gsp_national(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" + ) + db_session.add_all(forecasts) + db_session.commit() + + app.dependency_overrides[get_session] = lambda: db_session + + response = api_client.get("/v0/solar/GB/gsp/0/forecast") + + assert response.status_code == 200 + + _ = [ForecastValue(**f) for f in response.json()] + + def test_read_latest_one_gsp_filter_creation_utc(db_session, api_client): """Check main solar/GB/gsp/{gsp_id}/forecast route works"""