From 0cf0ff5f94166fc0ee828c1cabd4e1319bd717b6 Mon Sep 17 00:00:00 2001 From: Theo Pascoli Date: Wed, 18 Sep 2024 16:33:39 +0200 Subject: [PATCH] add versioning --- antarest/study/business/link_management.py | 6 ++-- .../variantstudy/model/command/create_link.py | 2 +- .../storage/business/test_arealink_manager.py | 32 ++++++++++++++++++- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/antarest/study/business/link_management.py b/antarest/study/business/link_management.py index c4b07b8004..38720f7765 100644 --- a/antarest/study/business/link_management.py +++ b/antarest/study/business/link_management.py @@ -37,8 +37,8 @@ class LinkUIDTO(BaseModel): color: str - width: float = 1 - style: LinkStyle = "plain" + width: float + style: LinkStyle class LinkInfoDTOBase(BaseModel): @@ -190,7 +190,7 @@ def update_links_props( self, study: RawStudy, update_links_by_ids: t.Mapping[t.Tuple[str, str], LinkOutput], - ) -> dict[tuple[str, str], BaseModel]: + ) -> dict[tuple[str, str], LinkOutput]: old_links_by_ids = self.get_all_links_props(study) new_links_by_ids = {} file_study = self.storage_service.get_storage(study).get_raw(study) diff --git a/antarest/study/storage/variantstudy/model/command/create_link.py b/antarest/study/storage/variantstudy/model/command/create_link.py index 2b7aece2d9..b1961efd5e 100644 --- a/antarest/study/storage/variantstudy/model/command/create_link.py +++ b/antarest/study/storage/variantstudy/model/command/create_link.py @@ -17,7 +17,7 @@ from antarest.core.model import JSON from antarest.core.utils.utils import assert_this from antarest.matrixstore.model import MatrixData -from antarest.study.storage.rawstudy.model.filesystem.config.links import AssetType, TransmissionCapacity +from antarest.study.storage.rawstudy.model.filesystem.config.links import AssetType, LinkStyle, TransmissionCapacity from antarest.study.storage.rawstudy.model.filesystem.config.model import FileStudyTreeConfig, Link from antarest.study.storage.rawstudy.model.filesystem.factory import FileStudy from antarest.study.storage.variantstudy.business.utils import strip_matrix_protocol, validate_matrix diff --git a/tests/storage/business/test_arealink_manager.py b/tests/storage/business/test_arealink_manager.py index ee115ae6d6..55627e799c 100644 --- a/tests/storage/business/test_arealink_manager.py +++ b/tests/storage/business/test_arealink_manager.py @@ -166,7 +166,7 @@ def test_area_crud(empty_study: FileStudy, matrix_service: SimpleMatrixService): # noinspection PyArgumentList study = VariantStudy( id=variant_id, - version="900", + version="-1", path=str(empty_study.config.study_path), additional_data=StudyAdditionalData(), ) @@ -235,6 +235,7 @@ def test_area_crud(empty_study: FileStudy, matrix_service: SimpleMatrixService): ) area_manager.create_area(study, AreaCreationDTO(name="test2", type=AreaType.AREA)) + study.version = 880 link_manager.create_link( study, LinkInfoDTO820( @@ -267,6 +268,35 @@ def test_area_crud(empty_study: FileStudy, matrix_service: SimpleMatrixService): ], RequestParameters(DEFAULT_ADMIN_USER), ) + study.version = 810 + link_manager.create_link( + study, + LinkInfoDTOBase( + area1="test", + area2="test2", + ), + ) + variant_study_service.append_commands.assert_called_with( + variant_id, + [ + CommandDTO( + action=CommandName.CREATE_LINK.value, + args={ + "area1": "test", + "area2": "test2", + "parameters": { + "hurdles-cost": False, + "loop-flow": False, + "use-phase-shifter": False, + "transmission-capacities": TransmissionCapacity.ENABLED, + "asset-type": AssetType.AC, + "display-comments": True, + }, + }, + ), + ], + RequestParameters(DEFAULT_ADMIN_USER), + ) link_manager.delete_link(study, "test", "test2") variant_study_service.append_commands.assert_called_with( variant_id,