forked from equinor/fmu-dataio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TST: Add create_case_metadata integration test
This test runs ert with a minimal configuration that just ensure the workflow functions correct and some patched data ends up in the fmu case export. It does not do more rigorous validating of the exported data.
- Loading branch information
Showing
13 changed files
with
190 additions
and
119 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import os | ||
import pathlib | ||
import shutil | ||
from textwrap import dedent | ||
|
||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def base_ert_config() -> str: | ||
return dedent( | ||
r""" | ||
DEFINE <USER> user | ||
DEFINE <SCRATCH> $DATAIO_TMP_PATH/scratch | ||
DEFINE <CASE_DIR> snakeoil | ||
DEFINE <SUMO_ENV> dev | ||
DEFINE <SUMO_CASEPATH> <SCRATCH>/<USER>/<CASE_DIR> | ||
NUM_REALIZATIONS 5 | ||
QUEUE_SYSTEM LOCAL | ||
QUEUE_OPTION LOCAL MAX_RUNNING 5 | ||
RANDOM_SEED 123456 | ||
RUNPATH <SCRATCH>/<USER>/<CASE_DIR>/realization-<IENS>/iter-<ITER>/ | ||
""" | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def fmu_snakeoil_project(tmp_path, monkeypatch, base_ert_config, global_config2_path): | ||
"""Makes a skeleton FMU project structure into a tmp_path, copying global_config2 | ||
into it with a basic ert config that can be appended onto.""" | ||
monkeypatch.setenv("DATAIO_TMP_PATH", str(tmp_path)) | ||
|
||
os.makedirs(tmp_path / "eclipse/model") | ||
for app in ("ert", "rms"): | ||
os.makedirs(tmp_path / f"{app}/bin") | ||
os.makedirs(tmp_path / f"{app}/input") | ||
os.makedirs(tmp_path / f"{app}/model") | ||
os.makedirs(tmp_path / "rms/model/snakeoil.rms13.1.2") | ||
|
||
os.makedirs(tmp_path / "fmuconfig/output") | ||
shutil.copy(global_config2_path, tmp_path / "fmuconfig/output/") | ||
|
||
os.makedirs(tmp_path / "ert/bin/workflows") | ||
pathlib.Path(tmp_path / "ert/bin/workflows/xhook_create_case_metadata").write_text( | ||
"WF_CREATE_CASE_METADATA " | ||
"<SCRATCH>/<USER>/<CASE_DIR> " # ert case root | ||
"<CONFIG_PATH> " # ert config path | ||
"<CASE_DIR> " # ert case dir | ||
"<USER>", # ert username | ||
encoding="utf-8", | ||
) | ||
|
||
pathlib.Path(tmp_path / "ert/model/snakeoil.ert").write_text( | ||
base_ert_config, encoding="utf-8" | ||
) | ||
|
||
return tmp_path |
Oops, something went wrong.