From 4e0f38d74814c4541b20b3d6e3c124833dbe303e Mon Sep 17 00:00:00 2001 From: belthlemar Date: Tue, 21 Jan 2025 16:43:55 +0100 Subject: [PATCH] fix one test --- .../variantstudy/model/command/test_remove_link.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/variantstudy/model/command/test_remove_link.py b/tests/variantstudy/model/command/test_remove_link.py index 832d8db20b..f183f96ecd 100644 --- a/tests/variantstudy/model/command/test_remove_link.py +++ b/tests/variantstudy/model/command/test_remove_link.py @@ -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 @@ -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"]} @@ -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(