Skip to content

Commit

Permalink
Refactor(export) : fix tests units (#1646)
Browse files Browse the repository at this point in the history
  • Loading branch information
TLAIDI committed Jul 24, 2023
1 parent 0154d6b commit f0b9798
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
1 change: 0 additions & 1 deletion antarest/study/storage/abstract_storage_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ def export_study_flat(
)

shutil.copytree(src=path_study, dst=dest, ignore=ignore_patterns)

if outputs and output_src_path.is_dir():
if output_dest_path.exists():
shutil.rmtree(output_dest_path)
Expand Down
11 changes: 6 additions & 5 deletions tests/storage/business/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from antarest.core.config import Config, StorageConfig
from antarest.study.model import DEFAULT_WORKSPACE_NAME, RawStudy
from antarest.study.storage.rawstudy.raw_study_service import RawStudyService
from antarest.study.storage.abstract_storage_service import export_study_flat


@pytest.mark.unit_test
Expand Down Expand Up @@ -105,17 +106,17 @@ def test_export_flat(tmp_path: Path):
study_factory.create_from_fs.return_value = study_tree

study = RawStudy(id="id", path=root)
path_study = Path(study.path)

study_service.export_study_flat(
study, tmp_path / "copy_with_output", outputs=True
)
export_study_flat(path_study, tmp_path / "copy_with_output", outputs=True)

copy_with_output_hash = dirhash(tmp_path / "copy_with_output", "md5")

assert root_hash == copy_with_output_hash

study_service.export_study_flat(
study, tmp_path / "copy_without_output", outputs=False
path_study = Path(study.path)
export_study_flat(
path_study, tmp_path / "copy_without_output", outputs=False
)

copy_without_output_hash = dirhash(tmp_path / "copy_without_output", "md5")
Expand Down
6 changes: 1 addition & 5 deletions tests/storage/integration/test_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from antarest.matrixstore.service import MatrixService
from antarest.study.main import build_study_service
from antarest.study.model import DEFAULT_WORKSPACE_NAME, RawStudy
from antarest.study.storage.utils import export_study_flat
from antarest.study.storage.abstract_storage_service import export_study_flat
from antarest.study.storage.variantstudy.business.matrix_constants_generator import (
GeneratorMatrixConstants,
)
Expand Down Expand Up @@ -103,13 +103,11 @@ def test_exporter_file_no_output(
@pytest.mark.parametrize(
"output_list", [None, [], ["20201014-1427eco"], ["20201014-1430adq-2"]]
)
@pytest.mark.parametrize("denormalize", [True, False])
def test_export_flat(
tmp_path: Path,
sta_mini_zip_path: Path,
outputs: bool,
output_list: Optional[List[str]],
denormalize: bool,
) -> None:
path_studies = tmp_path / "studies"
path_studies.mkdir(exist_ok=True)
Expand All @@ -123,10 +121,8 @@ def test_export_flat(
export_study_flat(
path_studies / "STA-mini",
export_path / "STA-mini-export",
Mock(),
outputs,
output_list,
denormalize=denormalize,
)

export_output_path = export_path / "STA-mini-export" / "output"
Expand Down

0 comments on commit f0b9798

Please sign in to comment.