From 65c324b2c0ee21ca1a42a1175d9a9f990eeca2ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85smund=20Birkeland?= Date: Thu, 29 Oct 2020 13:46:59 +0100 Subject: [PATCH] Test parser for empty string --- python/tests/res/fm/test_rms_run.py | 65 +++++++++++++++++++++++++ share/ert/forward-models/res/script/rms | 2 +- 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/python/tests/res/fm/test_rms_run.py b/python/tests/res/fm/test_rms_run.py index 435b0cc7c9..965570348b 100644 --- a/python/tests/res/fm/test_rms_run.py +++ b/python/tests/res/fm/test_rms_run.py @@ -54,6 +54,10 @@ """ +def _mocked_run(**kwargs): + print(kwargs) + + @tmpdir() @pytest.mark.parametrize( "test_input,expected_result", @@ -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() diff --git a/share/ert/forward-models/res/script/rms b/share/ert/forward-models/res/script/rms index 15b41d8348..87ba5bef82 100755 --- a/share/ert/forward-models/res/script/rms +++ b/share/ert/forward-models/res/script/rms @@ -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()