Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

Commit

Permalink
Test parser for empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
ManInFez committed Oct 30, 2020
1 parent d1618e5 commit 65c324b
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
65 changes: 65 additions & 0 deletions python/tests/res/fm/test_rms_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
"""


def _mocked_run(**kwargs):
print(kwargs)


@tmpdir()
@pytest.mark.parametrize(
"test_input,expected_result",
Expand Down Expand Up @@ -646,6 +650,67 @@ def test_run_allow_no_env(self):
allow_no_env=True,
)

def test_rms_job_script_parser(self):
with TestAreaContext("test_run"):
# Setup RMS project
with open("rms_config.yml", "w") as f:
json.dump(
{
"executable": os.path.realpath("bin/rms"),
"env": {"10.1.3": {"PATH": ""}},
},
f,
)

self.monkeypatch.setenv("RMS_TEST_VAR", "fdsgfdgfdsgfds")

os.mkdir("run_path")
os.mkdir("bin")
os.mkdir("project")
shutil.copy(
os.path.join(self.SOURCE_ROOT, "python/tests/res/fm/rms"), "bin"
)
self.monkeypatch.setenv("RMS_SITE_CONFIG", "rms_config.yml")

action = {"exit_status": 0}
with open("run_path/action.json", "w") as f:
f.write(json.dumps(action))

rms_exec = os.path.join(
self.SOURCE_ROOT, "share/ert/forward-models/res/script/rms"
)
subprocess.check_call(
[
rms_exec,
"--run-path",
"run_path",
"0",
"--version",
"10.1.3",
"project",
"--import-path",
"./",
"--export-path",
"./",
"workflow",
"",
]
)

subprocess.check_call(
[
rms_exec,
"--run-path",
"run_path",
"0",
"--version",
"10.1.3",
"project",
"workflow",
"-a",
]
)


if __name__ == "__main__":
unittest.main()
2 changes: 1 addition & 1 deletion share/ert/forward-models/res/script/rms
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def _build_argument_parser():

if __name__ == '__main__':
# old style jobs pass inn empty arguments as "" and causes argparse to fail
sys.argv = [arg for arg in sys.argv if arg != "" ]
sys.argv = [arg for arg in sys.argv if arg != ""]
arg_parser = _build_argument_parser()
args = arg_parser.parse_args()

Expand Down

0 comments on commit 65c324b

Please sign in to comment.