-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api,ui-config): add 'MILP' value option in 'Unit Commitment Mode…
…' field for study >= v8.8 (#2056)
- Loading branch information
Showing
6 changed files
with
174 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
tests/integration/study_data_blueprint/test_advanced_parameters.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
from http import HTTPStatus | ||
|
||
import pytest | ||
from starlette.testclient import TestClient | ||
|
||
from antarest.core.tasks.model import TaskStatus | ||
from tests.integration.utils import wait_task_completion | ||
|
||
|
||
class TestAdvancedParametersForm: | ||
""" | ||
Test the end points related to advanced parameters. | ||
Those tests use the "examples/studies/STA-mini.zip" Study, | ||
which contains the following areas: ["de", "es", "fr", "it"]. | ||
""" | ||
|
||
def test_get_advanced_parameters_values( | ||
self, | ||
client: TestClient, | ||
user_access_token: str, | ||
study_id: str, | ||
): | ||
"""Check `get_advanced_parameters_form_values` end point""" | ||
res = client.get( | ||
f"/v1/studies/{study_id}/config/advancedparameters/form", | ||
headers={"Authorization": f"Bearer {user_access_token}"}, | ||
) | ||
assert res.status_code == HTTPStatus.OK, res.json() | ||
actual = res.json() | ||
expected = { | ||
"accuracyOnCorrelation": "", | ||
"dayAheadReserveManagement": "global", | ||
"hydroHeuristicPolicy": "accommodate rule curves", | ||
"hydroPricingMode": "fast", | ||
"initialReservoirLevels": "cold start", | ||
"numberOfCoresMode": "maximum", | ||
"powerFluctuations": "free modulations", | ||
"renewableGenerationModelling": "clusters", | ||
"seedHydroCosts": 9005489, | ||
"seedInitialReservoirLevels": 10005489, | ||
"seedSpilledEnergyCosts": 7005489, | ||
"seedThermalCosts": 8005489, | ||
"seedTsgenHydro": 2005489, | ||
"seedTsgenLoad": 1005489, | ||
"seedTsgenSolar": 4005489, | ||
"seedTsgenThermal": 3005489, | ||
"seedTsgenWind": 5489, | ||
"seedTsnumbers": 5005489, | ||
"seedUnsuppliedEnergyCosts": 6005489, | ||
"sheddingPolicy": "shave peaks", | ||
"unitCommitmentMode": "fast", | ||
} | ||
assert actual == expected | ||
|
||
@pytest.mark.parametrize("study_version", [0, 880]) | ||
def test_set_advanced_parameters_values( | ||
self, client: TestClient, user_access_token: str, study_id: str, study_version: int | ||
): | ||
"""Check `set_advanced_parameters_values` end point""" | ||
obj = {"initialReservoirLevels": "hot start"} | ||
res = client.put( | ||
f"/v1/studies/{study_id}/config/advancedparameters/form", | ||
headers={"Authorization": f"Bearer {user_access_token}"}, | ||
json=obj, | ||
) | ||
assert res.status_code == HTTPStatus.OK, res.json() | ||
actual = res.json() | ||
assert actual is None | ||
|
||
if study_version: | ||
res = client.put( | ||
f"/v1/studies/{study_id}/upgrade", | ||
headers={"Authorization": f"Bearer {user_access_token}"}, | ||
params={"target_version": study_version}, | ||
) | ||
assert res.status_code == 200, res.json() | ||
|
||
task_id = res.json() | ||
task = wait_task_completion(client, user_access_token, task_id) | ||
assert task.status == TaskStatus.COMPLETED, task | ||
|
||
obj = {"unitCommitmentMode": "milp"} | ||
res = client.put( | ||
f"/v1/studies/{study_id}/config/advancedparameters/form", | ||
headers={"Authorization": f"Bearer {user_access_token}"}, | ||
json=obj, | ||
) | ||
if study_version: | ||
assert res.status_code == HTTPStatus.OK, res.json() | ||
else: | ||
assert res.status_code == 422 | ||
response = res.json() | ||
assert response["exception"] == "InvalidFieldForVersionError" | ||
assert response["description"] == "Unit commitment mode `MILP` only exists in v8.8+ studies" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters