Skip to content

Commit

Permalink
Merge commit '145bd84510b2c9f1f5ae9d81eb6a123c420bde61' into issue/na…
Browse files Browse the repository at this point in the history
…tional-creation-utc-limit

# Conflicts:
#	src/national.py
  • Loading branch information
peterdudfield committed Sep 27, 2023
2 parents 3224279 + 145bd84 commit 93c0e8a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
7 changes: 7 additions & 0 deletions src/gsp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Get GSP boundary data from eso """
import os
from typing import List, Optional, Union

import structlog
Expand Down Expand Up @@ -29,6 +30,7 @@


logger = structlog.stdlib.get_logger()
adjust_limit = float(os.getenv("ADJUST_MW_LIMIT", 0.0))


router = APIRouter()
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
19 changes: 19 additions & 0 deletions src/tests/test_gsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""

Expand Down

0 comments on commit 93c0e8a

Please sign in to comment.