diff --git a/antarest/study/storage/rawstudy/model/filesystem/config/files.py b/antarest/study/storage/rawstudy/model/filesystem/config/files.py index f6162d5637..3727f320ec 100644 --- a/antarest/study/storage/rawstudy/model/filesystem/config/files.py +++ b/antarest/study/storage/rawstudy/model/filesystem/config/files.py @@ -394,7 +394,14 @@ def _parse_renewables(root: Path, area: str) -> t.List[RenewableConfigType]: """ Parse the renewables INI file, return an empty list if missing. """ + + # Before version 8.1, we only have "Load", "Wind" and "Solar" objects. + # We can't use renewable clusters. version = _parse_version(root) + if version < 810: + return [] + + # Since version 8.1 of the solver, we can use "renewable clusters" objects. relpath = Path(f"input/renewables/clusters/{area}/list.ini") config_dict: t.Dict[str, t.Any] = _extract_data_from_file( root=root, diff --git a/tests/integration/variant_blueprint/test_renewable_cluster.py b/tests/integration/variant_blueprint/test_renewable_cluster.py index bdefbb402f..3dab4a946b 100644 --- a/tests/integration/variant_blueprint/test_renewable_cluster.py +++ b/tests/integration/variant_blueprint/test_renewable_cluster.py @@ -4,7 +4,9 @@ import pytest from starlette.testclient import TestClient +from antarest.core.tasks.model import TaskStatus from antarest.study.storage.rawstudy.model.filesystem.config.model import transform_name_to_id +from tests.integration.utils import wait_task_completion # noinspection SpellCheckingInspection @@ -23,6 +25,22 @@ def test_lifecycle( ) -> None: # sourcery skip: extract-duplicate-method + # ======================= + # Study version upgrade + # ======================= + + # We have an "old" study that we need to upgrade to version 810 + min_study_version = 810 + res = client.put( + f"/v1/studies/{study_id}/upgrade", + headers={"Authorization": f"Bearer {user_access_token}"}, + params={"target_version": min_study_version}, + ) + res.raise_for_status() + task_id = res.json() + task = wait_task_completion(client, user_access_token, task_id) + assert task.status == TaskStatus.COMPLETED, task + # ===================== # General Data Update # ===================== diff --git a/tests/storage/rawstudies/samples/__init__.py b/tests/storage/rawstudies/samples/__init__.py new file mode 100644 index 0000000000..773f16ec60 --- /dev/null +++ b/tests/storage/rawstudies/samples/__init__.py @@ -0,0 +1,3 @@ +from pathlib import Path + +ASSETS_DIR = Path(__file__).parent.resolve() diff --git a/tests/storage/rawstudies/samples/v810/sample1/study.antares b/tests/storage/rawstudies/samples/v810/sample1/study.antares index ae9f93dd07..a57109d3e4 100644 --- a/tests/storage/rawstudies/samples/v810/sample1/study.antares +++ b/tests/storage/rawstudies/samples/v810/sample1/study.antares @@ -1,5 +1,5 @@ [antares] -version = 800 +version = 810 caption = renewable-2-clusters-ts-prod-factor created = 1618413128 lastsave = 1625583204 diff --git a/tests/storage/rawstudies/test_factory.py b/tests/storage/rawstudies/test_factory.py index b3fd356f4f..e2cd4391b3 100644 --- a/tests/storage/rawstudies/test_factory.py +++ b/tests/storage/rawstudies/test_factory.py @@ -1,4 +1,3 @@ -from pathlib import Path from unittest.mock import Mock from antarest.core.interfaces.cache import CacheConstants @@ -7,10 +6,11 @@ from antarest.study.storage.rawstudy.model.filesystem.context import ContextServer from antarest.study.storage.rawstudy.model.filesystem.factory import StudyFactory from antarest.study.storage.rawstudy.model.filesystem.root.filestudytree import FileStudyTree +from tests.storage.rawstudies.samples import ASSETS_DIR -def test_renewable_subtree(): - path = Path(__file__).parent / "samples/v810/sample1" +def test_renewable_subtree() -> None: + path = ASSETS_DIR / "v810/sample1" context: ContextServer = Mock(specs=ContextServer) config = build(path, "") assert config.get_renewable_ids("area") == ["la_rochelle", "oleron"] @@ -41,8 +41,8 @@ def test_renewable_subtree(): } -def test_factory_cache(): - path = Path(__file__).parent / "samples/v810/sample1" +def test_factory_cache() -> None: + path = ASSETS_DIR / "v810/sample1" cache = Mock() factory = StudyFactory(matrix=Mock(), resolver=Mock(), cache=cache) diff --git a/tests/storage/repository/filesystem/config/test_config_files.py b/tests/storage/repository/filesystem/config/test_config_files.py index 1b87692900..4f88115291 100644 --- a/tests/storage/repository/filesystem/config/test_config_files.py +++ b/tests/storage/repository/filesystem/config/test_config_files.py @@ -363,7 +363,7 @@ def test_parse_thermal_860(tmp_path: Path, version, caplog) -> None: def test_parse_renewables(tmp_path: Path) -> None: study_path = build_empty_files(tmp_path) - study_path.joinpath("study.antares").write_text("[antares] \n version = 700") + study_path.joinpath("study.antares").write_text("[antares] \n version = 810") ini_path = study_path.joinpath("input/renewables/clusters/fr/list.ini") # Error case: `input/renewables/clusters/fr` directory is missing.