Skip to content

Commit

Permalink
add versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoPascoli committed Sep 18, 2024
1 parent f3a9464 commit 0cf0ff5
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
6 changes: 3 additions & 3 deletions antarest/study/business/link_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@

class LinkUIDTO(BaseModel):
color: str
width: float = 1
style: LinkStyle = "plain"
width: float
style: LinkStyle


class LinkInfoDTOBase(BaseModel):
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 31 additions & 1 deletion tests/storage/business/test_arealink_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
)
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 0cf0ff5

Please sign in to comment.