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

Commit

Permalink
mock worflow.run to throw exception
Browse files Browse the repository at this point in the history
  • Loading branch information
xjules committed Nov 25, 2019
1 parent 35df829 commit 42a4a57
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions python/tests/res/job_queue/test_workflow_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from ecl.util.test import TestAreaContext
from res.util.substitution_list import SubstitutionList
from .workflow_common import WorkflowCommon
from unittest import mock


class WorkflowRunnerTest(ResTest):
Expand Down Expand Up @@ -96,6 +97,7 @@ def test_workflow_thread_cancel_external(self):
self.assertFileDoesNotExist("wait_cancelled_2")
self.assertFileDoesNotExist("wait_finished_2")


def test_workflow_failed_job(self):
with TestAreaContext("python/job_queue/workflow_runner_fails") as work_area:
WorkflowCommon.createExternalDumpJob()
Expand All @@ -108,16 +110,10 @@ def test_workflow_failed_job(self):
workflow_runner = WorkflowRunner(workflow, ert=None, context=SubstitutionList())

self.assertFalse(workflow_runner.isRunning())

workflow_runner.run()
workflow_runner.wait()
print('DBG errorlist: ', workflow_runner.workflowReport())
self.assertNotEqual(workflow_runner.runner_thread._exception, None)





with mock.patch.object(Workflow, 'run', side_effect=Exception('mocked workflow error')):
workflow_runner.run()
workflow_runner.wait()
self.assertNotEqual(workflow_runner.runner_thread._exception, None)

def test_workflow_success(self):
with TestAreaContext("python/job_queue/workflow_runner_fast") as work_area:
Expand Down

0 comments on commit 42a4a57

Please sign in to comment.