Skip to content

Commit

Permalink
fix one test
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinBelthle committed Jan 21, 2025
1 parent befd868 commit 4e0f38d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tests/variantstudy/model/command/test_remove_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
import pytest
from checksumdir import dirhash
from pydantic import ValidationError
from sqlalchemy.orm import Session

from antarest.study.model import STUDY_VERSION_8_8
from antarest.study.model import STUDY_VERSION_8_8, RawStudy
from antarest.study.storage.rawstudy.model.filesystem.config.files import build
from antarest.study.storage.rawstudy.model.filesystem.config.model import transform_name_to_id
from antarest.study.storage.rawstudy.model.filesystem.factory import FileStudy
Expand Down Expand Up @@ -93,9 +94,14 @@ def make_study(tmpdir: Path, version: int) -> FileStudy:
return FileStudy(config, FileStudyTree(Mock(), config))

@pytest.mark.parametrize("version", [810, 820])
def test_apply(self, tmpdir: Path, command_context: CommandContext, version: int) -> None:
def test_apply(self, tmpdir: Path, command_context: CommandContext, version: int, db_session: Session) -> None:
empty_study = self.make_study(tmpdir, version)
study_version = empty_study.config.version
study_path = empty_study.config.study_path

raw_study = RawStudy(id=empty_study.config.study_id, version=str(study_version), path=str(study_path))
db_session.add(raw_study)
db_session.commit()

# Create some areas
areas = {transform_name_to_id(area, lower=True): area for area in ["Area_X", "Area_Y", "Area_Z"]}
Expand All @@ -122,8 +128,8 @@ def test_apply(self, tmpdir: Path, command_context: CommandContext, version: int
########################################################################################

# Line ending of the `settings/scenariobuilder.dat` must be reset before checksum
reset_line_separator(empty_study.config.study_path.joinpath("settings/scenariobuilder.dat"))
hash_before_removal = dirhash(empty_study.config.study_path, "md5")
reset_line_separator(study_path.joinpath("settings/scenariobuilder.dat"))
hash_before_removal = dirhash(study_path, "md5")

# Create a link between Area_X and Area_Z
output = CreateLink(
Expand Down

0 comments on commit 4e0f38d

Please sign in to comment.