Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoPascoli committed Sep 19, 2024
1 parent 26cdb3a commit 76188de
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
24 changes: 11 additions & 13 deletions antarest/study/business/link_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,15 @@
# This file is part of the Antares project.

import typing as t
from typing import Any, Dict, Tuple, Union

from pydantic import BaseModel, Field
from pydantic import BaseModel

from antarest.core.exceptions import ConfigFileNotFound, InvalidFieldForVersionError
from antarest.core.model import JSON
from antarest.study.business.all_optional_meta import all_optional_model, camel_case_model
from antarest.study.business.utils import execute_or_add_commands
from antarest.study.model import RawStudy
from antarest.study.storage.rawstudy.model.filesystem.config.links import (
LinkProperties,
LinkStyle,
)
from antarest.study.storage.rawstudy.model.filesystem.config.links import LinkProperties, LinkStyle
from antarest.study.storage.storage_service import StudyStorageService
from antarest.study.storage.variantstudy.model.command.common import FilteringOptions
from antarest.study.storage.variantstudy.model.command.create_link import CreateLink
Expand Down Expand Up @@ -52,8 +48,8 @@ class LinkInfoDTOBase(BaseModel):


class LinkInfoDTO820(LinkInfoDTOBase):
filter_synthesis: t.Optional[str] = FilteringOptions.FILTER_SYNTHESIS
filter_year_by_year: t.Optional[str] = FilteringOptions.FILTER_YEAR_BY_YEAR
filter_synthesis: t.Optional[str] = None
filter_year_by_year: t.Optional[str] = None


LinkInfoDTOType = t.Union[LinkInfoDTO820, LinkInfoDTOBase]
Expand All @@ -66,6 +62,10 @@ def create_link_info(version: int, **kwargs) -> LinkInfoDTOType:

if version >= 820:
link_info = LinkInfoDTO820(**kwargs)
if link_info.filter_synthesis is None:
link_info.filter_synthesis = FilteringOptions.FILTER_SYNTHESIS
if link_info.filter_year_by_year is None:
link_info.filter_year_by_year = FilteringOptions.FILTER_YEAR_BY_YEAR
else:
link_info = LinkInfoDTOBase(**kwargs)

Expand Down Expand Up @@ -110,10 +110,8 @@ def get_all_links(self, study: RawStudy, with_ui: bool = False) -> t.List[LinkIn
asset_type=links_config[link].get("asset-type"),
display_comments=links_config[link].get("display-comments"),
ui=ui_info,
filter_synthesis=links_config[link].get("filter-synthesis") if int(study.version) >= 820 else None,
filter_year_by_year=links_config[link].get("filter-year-by-year")
if int(study.version) >= 820
else None,
filter_synthesis=links_config[link].get("filter-synthesis"),
filter_year_by_year=links_config[link].get("filter-year-by-year"),
)
result.append(link_info_dto)
return result
Expand All @@ -140,7 +138,7 @@ def create_link(self, study: RawStudy, link_creation_info: LinkInfoDTOType) -> L
command = CreateLink(
area1=link_creation_info.area1,
area2=link_creation_info.area2,
parameters=self.create_parameters(int(study.version), link_creation_info),
parameters=self.create_parameters(int(study.version), link_info_dto),
command_context=self.storage_service.variant_study_service.command_factory.command_context,
)

Expand Down
2 changes: 0 additions & 2 deletions tests/storage/business/test_arealink_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,6 @@ def test_area_crud(empty_study: FileStudy, matrix_service: SimpleMatrixService):
version=-1,
area1="test",
area2="test2",
filter_synthesis=FilteringOptions.FILTER_SYNTHESIS,
filter_year_by_year=FilteringOptions.FILTER_YEAR_BY_YEAR,
),
)
assert empty_study.config.areas["test"].links.get("test2") is not None
Expand Down

0 comments on commit 76188de

Please sign in to comment.