Skip to content

Commit

Permalink
Add checks for required files
Browse files Browse the repository at this point in the history
  • Loading branch information
frode-aarstad committed Feb 5, 2025
1 parent 433ff9e commit 0feb0cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/everest_models/jobs/fm_well_trajectory/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ def main_entry_point(args=None):
if bool(e.dynamic) and not Path(f"{eclipse_model}.UNRST").exists():
args_parser.error(f"Missing {eclipse_model}.UNRST file")

if (
Path(f"{eclipse_model}.EGRID").exists()
and not Path(f"{eclipse_model}.INIT").exists()
):
if not Path(f"{eclipse_model}.EGRID").exists():
args_parser.error(f"Missing {eclipse_model}.EGRID file")

if not Path(f"{eclipse_model}.INIT").exists():
args_parser.error(f"Missing {eclipse_model}.INIT file")

mlt_guide_points = well_trajectory_resinsight(
Expand Down
9 changes: 6 additions & 3 deletions tests/jobs/well_trajectory/test_well_trajectory_resinsight.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,17 @@ def test_well_trajectory_resinsight_main_entry_point_no_mlt_missing_date(
main_entry_point("-c config_missing_date.yml -E SPE1CASE1".split())


def test_validate_files_required_for_model(copy_testdata_tmpdir, capsys):
@pytest.mark.parametrize("remove_file", ["SPE1CASE1.EGRID", "SPE1CASE1.INIT"])
def test_checking_for_files_required_for_model(
remove_file, copy_testdata_tmpdir, capsys
):
copy_testdata_tmpdir(Path(TEST_DATA) / "resinsight")
os.remove("SPE1CASE1.INIT")
os.remove(remove_file)
with pytest.raises(SystemExit) as excinfo:
main_entry_point("-c config.yml -E SPE1CASE1".split())
assert excinfo.value.code == 2
captured = capsys.readouterr()
assert "Missing SPE1CASE1.INIT file" in captured.err
assert f"Missing {remove_file} file" in captured.err


def test_validate_files_required_for_dynamic_perforation(copy_testdata_tmpdir, capsys):
Expand Down

0 comments on commit 0feb0cd

Please sign in to comment.