Skip to content

Commit fdb774f

Browse files
committed
fixup! Validate workflow job args against hook runtime fixtures
address review
1 parent b157fcc commit fdb774f

File tree

1 file changed

+11
-56
lines changed

1 file changed

+11
-56
lines changed

tests/ert/unit_tests/config/test_ert_config.py

+11-56
Original file line numberDiff line numberDiff line change
@@ -1995,8 +1995,9 @@ def run(self, *args):
19951995
assert ert_config.substitutions["<FOO2>"] == "ertconfig_foo2"
19961996

19971997

1998+
@pytest.fixture
19981999
@pytest.mark.usefixtures("use_tmpdir")
1999-
def test_ert_script_hook_pre_experiment_but_asks_for_storage():
2000+
def set_me_up():
20002001
workflow_file_path = os.path.join(os.getcwd(), "workflow")
20012002
with open(workflow_file_path, mode="w", encoding="utf-8") as fh:
20022003
fh.write("TEST_SCRIPT")
@@ -2005,14 +2006,16 @@ def test_ert_script_hook_pre_experiment_but_asks_for_storage():
20052006
fh.write(
20062007
dedent(
20072008
f"""
2008-
NUM_REALIZATIONS 1
2009+
NUM_REALIZATIONS 1
20092010
2010-
LOAD_WORKFLOW {workflow_file_path} workflow_alias
2011-
HOOK_WORKFLOW workflow_alias PRE_EXPERIMENT
2012-
"""
2011+
LOAD_WORKFLOW {workflow_file_path} workflow_alias
2012+
HOOK_WORKFLOW workflow_alias PRE_EXPERIMENT
2013+
"""
20132014
)
20142015
)
20152016

2017+
2018+
def test_ert_script_hook_pre_experiment_but_asks_for_storage(set_me_up):
20162019
class SomeScript(ErtScript):
20172020
def run(self, storage: Storage):
20182021
pass
@@ -2032,23 +2035,7 @@ def run(self, storage: Storage):
20322035

20332036

20342037
@pytest.mark.usefixtures("use_tmpdir")
2035-
def test_ert_script_hook_pre_experiment_but_asks_for_ensemble():
2036-
workflow_file_path = os.path.join(os.getcwd(), "workflow")
2037-
with open(workflow_file_path, mode="w", encoding="utf-8") as fh:
2038-
fh.write("TEST_SCRIPT")
2039-
2040-
with open("config.ert", mode="w", encoding="utf-8") as fh:
2041-
fh.write(
2042-
dedent(
2043-
f"""
2044-
NUM_REALIZATIONS 1
2045-
2046-
LOAD_WORKFLOW {workflow_file_path} workflow_alias
2047-
HOOK_WORKFLOW workflow_alias PRE_EXPERIMENT
2048-
"""
2049-
)
2050-
)
2051-
2038+
def test_ert_script_hook_pre_experiment_but_asks_for_ensemble(set_me_up):
20522039
class SomeScript(ErtScript):
20532040
def run(self, ensemble: LocalEnsemble):
20542041
pass
@@ -2068,23 +2055,7 @@ def run(self, ensemble: LocalEnsemble):
20682055

20692056

20702057
@pytest.mark.usefixtures("use_tmpdir")
2071-
def test_ert_script_hook_pre_experiment_but_asks_for_random_seed():
2072-
workflow_file_path = os.path.join(os.getcwd(), "workflow")
2073-
with open(workflow_file_path, mode="w", encoding="utf-8") as fh:
2074-
fh.write("TEST_SCRIPT")
2075-
2076-
with open("config.ert", mode="w", encoding="utf-8") as fh:
2077-
fh.write(
2078-
dedent(
2079-
f"""
2080-
NUM_REALIZATIONS 1
2081-
2082-
LOAD_WORKFLOW {workflow_file_path} workflow_alias
2083-
HOOK_WORKFLOW workflow_alias PRE_EXPERIMENT
2084-
"""
2085-
)
2086-
)
2087-
2058+
def test_ert_script_hook_pre_experiment_but_asks_for_random_seed(set_me_up):
20882059
class SomeScript(ErtScript):
20892060
def run(self, random_seed: int):
20902061
pass
@@ -2099,23 +2070,7 @@ def run(self, random_seed: int):
20992070

21002071

21012072
@pytest.mark.usefixtures("use_tmpdir")
2102-
def test_ert_script_hook_pre_experiment_essettings_fails():
2103-
workflow_file_path = os.path.join(os.getcwd(), "workflow")
2104-
with open(workflow_file_path, mode="w", encoding="utf-8") as fh:
2105-
fh.write("TEST_SCRIPT")
2106-
2107-
with open("config.ert", mode="w", encoding="utf-8") as fh:
2108-
fh.write(
2109-
dedent(
2110-
f"""
2111-
NUM_REALIZATIONS 1
2112-
2113-
LOAD_WORKFLOW {workflow_file_path} workflow_alias
2114-
HOOK_WORKFLOW workflow_alias PRE_EXPERIMENT
2115-
"""
2116-
)
2117-
)
2118-
2073+
def test_ert_script_hook_pre_experiment_essettings_fails(set_me_up):
21192074
class SomeScript(ErtScript):
21202075
def run(self, es_settings: ESSettings):
21212076
pass

0 commit comments

Comments
 (0)