def test_read_internal_function(self): with TestAreaContext("python/job_queue/workflow_job") as work_area: WorkflowCommon.createInternalFunctionJob() WorkflowCommon.createErtScriptsJob() config = alloc_config() workflow_job = alloc_from_file("SELECT_CASE", config, "select_case_job") self.assertEqual(workflow_job.name(), "SELECT_CASE") self.assertTrue(workflow_job.isInternal()) self.assertEqual(workflow_job.functionName(), "enkf_main_select_case_JOB") self.assertFalse(workflow_job.isInternalScript()) self.assertIsNone(workflow_job.getInternalScriptPath()) workflow_job = alloc_from_file("SUBTRACT", config, "subtract_script_job") self.assertEqual(workflow_job.name(), "SUBTRACT") self.assertTrue(workflow_job.isInternal()) self.assertIsNone(workflow_job.functionName()) self.assertTrue(workflow_job.isInternalScript()) self.assertTrue(workflow_job.getInternalScriptPath().endswith( "subtract_script.py"))
def test_run_internal_script(self): with TestAreaContext("python/job_queue/workflow_job") as work_area: WorkflowCommon.createErtScriptsJob() config = alloc_config() job = alloc_from_file("SUBTRACT", config, "subtract_script_job") result = job.run(None, ["1", "2"]) self.assertEqual(result, -1)
def createScripts(): WorkflowCommon.createErtScriptsJob() with open("syntax_error_script.py", "w") as f: f.write("from ert.enkf not_legal_syntax ErtScript\n") with open("import_error_script.py", "w") as f: f.write("from ert.enkf import DoesNotExist\n") with open("empty_script.py", "w") as f: f.write("from ert.enkf import ErtScript\n")
def test_workflow_joblist_with_files(self): with TestAreaContext("python/job_queue/workflow_joblist") as work_area: WorkflowCommon.createErtScriptsJob() WorkflowCommon.createExternalDumpJob() WorkflowCommon.createInternalFunctionJob() joblist = WorkflowJoblist() joblist.addJobFromFile("DUMP_JOB", "dump_job") joblist.addJobFromFile("SELECT_CASE_JOB", "select_case_job") joblist.addJobFromFile("SUBTRACT_SCRIPT_JOB", "subtract_script_job") self.assertTrue("DUMP_JOB" in joblist) self.assertTrue("SELECT_CASE_JOB" in joblist) self.assertTrue("SUBTRACT_SCRIPT_JOB" in joblist) self.assertFalse((joblist["DUMP_JOB"]).isInternal()) self.assertTrue((joblist["SELECT_CASE_JOB"]).isInternal()) self.assertTrue((joblist["SUBTRACT_SCRIPT_JOB"]).isInternal())
def test_read_internal_function(self): with TestAreaContext("python/job_queue/workflow_job") as work_area: WorkflowCommon.createInternalFunctionJob() WorkflowCommon.createErtScriptsJob() config = alloc_config() workflow_job = alloc_from_file("SELECT_CASE", config, "select_case_job") self.assertEqual(workflow_job.name(), "SELECT_CASE") self.assertTrue(workflow_job.isInternal()) self.assertEqual(workflow_job.functionName(), "enkf_main_select_case_JOB") self.assertFalse(workflow_job.isInternalScript()) self.assertIsNone(workflow_job.getInternalScriptPath()) workflow_job = alloc_from_file("SUBTRACT", config, "subtract_script_job") self.assertEqual(workflow_job.name(), "SUBTRACT") self.assertTrue(workflow_job.isInternal()) self.assertIsNone(workflow_job.functionName()) self.assertTrue(workflow_job.isInternalScript()) self.assertTrue(workflow_job.getInternalScriptPath().endswith("subtract_script.py"))