<s> import copy <EOL> import uuid <EOL> import mock <EOL> import six <EOL> import yaml <EOL> from mistralclient . api . v2 import executions <EOL> from mistralclient . api . v2 import tasks <EOL> from mistralclient . api . v2 import workbooks <EOL> from mistralclient . api . v2 import workflows <EOL> from oslo_config import cfg <EOL> import st2tests . config as tests_config <EOL> tests_config . parse_args ( ) <EOL> cfg . CONF . set_override ( '<STR_LIT>' , <NUM_LIT:100> , group = '<STR_LIT>' ) <EOL> cfg . CONF . set_override ( '<STR_LIT>' , <NUM_LIT:200> , group = '<STR_LIT>' ) <EOL> cfg . CONF . set_override ( '<STR_LIT>' , <NUM_LIT:200> , group = '<STR_LIT>' ) <EOL> import st2common . bootstrap . runnersregistrar as runners_registrar <EOL> from st2actions . runners . localrunner import LocalShellRunner <EOL> from st2actions . runners . mistral . v2 import MistralRunner <EOL> from st2common . constants import action as action_constants <EOL> from st2common . models . api . action import ActionAPI <EOL> from st2common . models . db . liveaction import LiveActionDB <EOL> from st2common . persistence . action import Action <EOL> from st2common . persistence . liveaction import LiveAction <EOL> from st2common . services import action as action_service <EOL> from st2common . transport . liveaction import LiveActionPublisher <EOL> from st2common . transport . publishers import CUDPublisher <EOL> from st2tests import DbTestCase <EOL> from st2tests . fixturesloader import FixturesLoader <EOL> from tests . unit . base import MockLiveActionPublisher <EOL> TEST_FIXTURES = { <EOL> '<STR_LIT>' : [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] , <EOL> '<STR_LIT>' : [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] <EOL> } <EOL> PACK = '<STR_LIT>' <EOL> LOADER = FixturesLoader ( ) <EOL> FIXTURES = LOADER . load_fixtures ( fixtures_pack = PACK , fixtures_dict = TEST_FIXTURES ) <EOL> WB1_YAML_FILE_NAME = TEST_FIXTURES [ '<STR_LIT>' ] [ <NUM_LIT:1> ] <EOL> WB1_YAML_FILE_PATH = LOADER . get_fixture_file_path_abs ( PACK , '<STR_LIT>' , WB1_YAML_FILE_NAME ) <EOL> WB1_SPEC = FIXTURES [ '<STR_LIT>' ] [ WB1_YAML_FILE_NAME ] <EOL> WB1_YAML = yaml . safe_dump ( WB1_SPEC , default_flow_style = False ) <EOL> WB1_NAME = '<STR_LIT>' % ( PACK , WB1_YAML_FILE_NAME . replace ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> WB1 = workbooks . Workbook ( None , { '<STR_LIT:name>' : WB1_NAME , '<STR_LIT>' : WB1_YAML } ) <EOL> WB1_MAIN_EXEC = { '<STR_LIT:id>' : str ( uuid . uuid4 ( ) ) , '<STR_LIT:state>' : '<STR_LIT>' } <EOL> WB1_MAIN_EXEC [ '<STR_LIT>' ] = WB1_NAME + '<STR_LIT>' <EOL> WB1_MAIN_EXEC_ERRORED = copy . deepcopy ( WB1_MAIN_EXEC ) <EOL> WB1_MAIN_EXEC_ERRORED [ '<STR_LIT:state>' ] = '<STR_LIT>' <EOL> WB1_MAIN_TASK1 = { '<STR_LIT:id>' : str ( uuid . uuid4 ( ) ) , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:state>' : '<STR_LIT>' } <EOL> WB1_MAIN_TASKS = [ tasks . Task ( None , WB1_MAIN_TASK1 ) ] <EOL> WB1_MAIN_TASK_ID = WB1_MAIN_TASK1 [ '<STR_LIT:id>' ] <EOL> WB1_SUB1_EXEC = { '<STR_LIT:id>' : str ( uuid . uuid4 ( ) ) , '<STR_LIT:state>' : '<STR_LIT>' , '<STR_LIT>' : WB1_MAIN_TASK_ID } <EOL> WB1_SUB1_EXEC [ '<STR_LIT>' ] = WB1_NAME + '<STR_LIT>' <EOL> WB1_SUB1_EXEC_ERRORED = copy . deepcopy ( WB1_SUB1_EXEC ) <EOL> WB1_SUB1_EXEC_ERRORED [ '<STR_LIT:state>' ] = '<STR_LIT>' <EOL> WB1_SUB1_TASK1 = { '<STR_LIT:id>' : str ( uuid . uuid4 ( ) ) , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:state>' : '<STR_LIT>' } <EOL> WB1_SUB1_TASK2 = { '<STR_LIT:id>' : str ( uuid . uuid4 ( ) ) , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:state>' : '<STR_LIT>' } <EOL> WB1_SUB1_TASKS = [ tasks . Task ( None , WB1_SUB1_TASK1 ) , tasks . Task ( None , WB1_SUB1_TASK2 ) ] <EOL> WF1_YAML_FILE_NAME = TEST_FIXTURES [ '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> WF1_YAML_FILE_PATH = LOADER . get_fixture_file_path_abs ( PACK , '<STR_LIT>' , WF1_YAML_FILE_NAME ) <EOL> WF1_SPEC = FIXTURES [ '<STR_LIT>' ] [ WF1_YAML_FILE_NAME ] <EOL> WF1_YAML = yaml . safe_dump ( WF1_SPEC , default_flow_style = False ) <EOL> WF1_NAME = '<STR_LIT>' % ( PACK , WF1_YAML_FILE_NAME . replace ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> WF1 = workflows . Workflow ( None , { '<STR_LIT:name>' : WF1_NAME , '<STR_LIT>' : WF1_YAML } ) <EOL> WF1_EXEC = { '<STR_LIT:id>' : str ( uuid . uuid4 ( ) ) , '<STR_LIT:state>' : '<STR_LIT>' , '<STR_LIT>' : WF1_NAME } <EOL> WF1_EXEC_NOT_RERUNABLE = copy . deepcopy ( WF1_EXEC ) <EOL> WF1_EXEC_NOT_RERUNABLE [ '<STR_LIT:state>' ] = '<STR_LIT>' <EOL> WF1_TASK1 = { '<STR_LIT:id>' : str ( uuid . uuid4 ( ) ) , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:state>' : '<STR_LIT>' } <EOL> WF1_TASK2 = { '<STR_LIT:id>' : str ( uuid . uuid4 ( ) ) , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:state>' : '<STR_LIT>' } <EOL> WF1_TASKS = [ tasks . Task ( None , WF1_TASK1 ) , tasks . Task ( None , WF1_TASK2 ) ] <EOL> ACTION_PARAMS = { '<STR_LIT>' : '<STR_LIT>' } <EOL> NON_EMPTY_RESULT = '<STR_LIT>' <EOL> @ mock . patch . object ( LocalShellRunner , '<STR_LIT>' , mock . <EOL> MagicMock ( return_value = ( action_constants . LIVEACTION_STATUS_SUCCEEDED , <EOL> NON_EMPTY_RESULT , None ) ) ) <EOL> @ mock . patch . object ( CUDPublisher , '<STR_LIT>' , mock . MagicMock ( return_value = None ) ) <EOL> @ mock . patch . object ( CUDPublisher , '<STR_LIT>' , <EOL> mock . MagicMock ( side_effect = MockLiveActionPublisher . publish_create ) ) <EOL> @ mock . patch . object ( LiveActionPublisher , '<STR_LIT>' , <EOL> mock . MagicMock ( side_effect = MockLiveActionPublisher . publish_state ) ) <EOL> class MistralRunnerTest ( DbTestCase ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> super ( MistralRunnerTest , cls ) . setUpClass ( ) <EOL> runners_registrar . register_runner_types ( ) <EOL> for _ , fixture in six . iteritems ( FIXTURES [ '<STR_LIT>' ] ) : <EOL> instance = ActionAPI ( ** fixture ) <EOL> Action . add_or_update ( ActionAPI . to_model ( instance ) ) <EOL> def setUp ( self ) : <EOL> super ( MistralRunnerTest , self ) . setUp ( ) <EOL> cfg . CONF . set_override ( '<STR_LIT>' , '<STR_LIT>' , group = '<STR_LIT>' ) <EOL> @ mock . patch . object ( <EOL> workflows . WorkflowManager , '<STR_LIT:list>' , <EOL> mock . MagicMock ( return_value = [ ] ) ) <EOL> @ mock . patch . object ( <EOL> workflows . WorkflowManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = WF1 ) ) <EOL> @ mock . patch . object ( <EOL> workflows . WorkflowManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = [ WF1 ] ) ) <EOL> @ mock . patch . object ( <EOL> executions . ExecutionManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = executions . Execution ( None , WF1_EXEC ) ) ) <EOL> @ mock . patch . object ( <EOL> MistralRunner , '<STR_LIT>' , <EOL> mock . MagicMock ( <EOL> return_value = ( action_constants . LIVEACTION_STATUS_RUNNING , <EOL> { '<STR_LIT>' : [ ] } , <EOL> { '<STR_LIT>' : str ( uuid . uuid4 ( ) ) } ) <EOL> ) <EOL> ) <EOL> def test_resume_option ( self ) : <EOL> MistralRunner . entry_point = mock . PropertyMock ( return_value = WF1_YAML_FILE_PATH ) <EOL> liveaction1 = LiveActionDB ( action = WF1_NAME , parameters = ACTION_PARAMS ) <EOL> liveaction1 , execution1 = action_service . request ( liveaction1 ) <EOL> self . assertFalse ( MistralRunner . resume . called ) <EOL> context = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : execution1 . id , <EOL> '<STR_LIT>' : [ '<STR_LIT:x>' ] <EOL> } <EOL> } <EOL> liveaction2 = LiveActionDB ( action = WF1_NAME , parameters = ACTION_PARAMS , context = context ) <EOL> liveaction2 , execution2 = action_service . request ( liveaction2 ) <EOL> liveaction2 = LiveAction . get_by_id ( str ( liveaction2 . id ) ) <EOL> self . assertEqual ( liveaction2 . status , action_constants . LIVEACTION_STATUS_RUNNING ) <EOL> task_specs = { <EOL> '<STR_LIT:x>' : { <EOL> '<STR_LIT>' : False <EOL> } <EOL> } <EOL> MistralRunner . resume . assert_called_with ( ex_ref = execution1 , task_specs = task_specs ) <EOL> @ mock . patch . object ( <EOL> workflows . WorkflowManager , '<STR_LIT:list>' , <EOL> mock . MagicMock ( return_value = [ ] ) ) <EOL> @ mock . patch . object ( <EOL> workflows . WorkflowManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = WF1 ) ) <EOL> @ mock . patch . object ( <EOL> workflows . WorkflowManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = [ WF1 ] ) ) <EOL> @ mock . patch . object ( <EOL> executions . ExecutionManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = executions . Execution ( None , WF1_EXEC ) ) ) <EOL> @ mock . patch . object ( <EOL> MistralRunner , '<STR_LIT>' , <EOL> mock . MagicMock ( <EOL> return_value = ( action_constants . LIVEACTION_STATUS_RUNNING , <EOL> { '<STR_LIT>' : [ ] } , <EOL> { '<STR_LIT>' : str ( uuid . uuid4 ( ) ) } ) <EOL> ) <EOL> ) <EOL> def test_resume_option_reset_tasks ( self ) : <EOL> MistralRunner . entry_point = mock . PropertyMock ( return_value = WF1_YAML_FILE_PATH ) <EOL> liveaction1 = LiveActionDB ( action = WF1_NAME , parameters = ACTION_PARAMS ) <EOL> liveaction1 , execution1 = action_service . request ( liveaction1 ) <EOL> self . assertFalse ( MistralRunner . resume . called ) <EOL> context = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : execution1 . id , <EOL> '<STR_LIT>' : [ '<STR_LIT:x>' , '<STR_LIT:y>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT:y>' ] <EOL> } <EOL> } <EOL> liveaction2 = LiveActionDB ( action = WF1_NAME , parameters = ACTION_PARAMS , context = context ) <EOL> liveaction2 , execution2 = action_service . request ( liveaction2 ) <EOL> liveaction2 = LiveAction . get_by_id ( str ( liveaction2 . id ) ) <EOL> self . assertEqual ( liveaction2 . status , action_constants . LIVEACTION_STATUS_RUNNING ) <EOL> task_specs = { <EOL> '<STR_LIT:x>' : { <EOL> '<STR_LIT>' : False <EOL> } , <EOL> '<STR_LIT:y>' : { <EOL> '<STR_LIT>' : True <EOL> } <EOL> } <EOL> MistralRunner . resume . assert_called_with ( ex_ref = execution1 , task_specs = task_specs ) <EOL> @ mock . patch . object ( <EOL> workflows . WorkflowManager , '<STR_LIT:list>' , <EOL> mock . MagicMock ( return_value = [ ] ) ) <EOL> @ mock . patch . object ( <EOL> workflows . WorkflowManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = WF1 ) ) <EOL> @ mock . patch . object ( <EOL> workflows . WorkflowManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = [ WF1 ] ) ) <EOL> @ mock . patch . object ( <EOL> executions . ExecutionManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = executions . Execution ( None , WF1_EXEC_NOT_RERUNABLE ) ) ) <EOL> @ mock . patch . object ( <EOL> executions . ExecutionManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = executions . Execution ( None , WF1_EXEC_NOT_RERUNABLE ) ) ) <EOL> @ mock . patch . object ( <EOL> tasks . TaskManager , '<STR_LIT:list>' , <EOL> mock . MagicMock ( return_value = WF1_TASKS ) ) <EOL> def test_resume_workflow_not_in_rerunable_state ( self ) : <EOL> MistralRunner . entry_point = mock . PropertyMock ( return_value = WF1_YAML_FILE_PATH ) <EOL> liveaction1 = LiveActionDB ( action = WF1_NAME , parameters = ACTION_PARAMS ) <EOL> liveaction1 , execution1 = action_service . request ( liveaction1 ) <EOL> context = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : execution1 . id , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] <EOL> } <EOL> } <EOL> liveaction2 = LiveActionDB ( action = WF1_NAME , parameters = ACTION_PARAMS , context = context ) <EOL> liveaction2 , execution2 = action_service . request ( liveaction2 ) <EOL> liveaction2 = LiveAction . get_by_id ( str ( liveaction2 . id ) ) <EOL> self . assertEqual ( liveaction2 . status , action_constants . LIVEACTION_STATUS_FAILED ) <EOL> self . assertIn ( '<STR_LIT>' , liveaction2 . result . get ( '<STR_LIT:error>' ) ) <EOL> @ mock . patch . object ( <EOL> workflows . WorkflowManager , '<STR_LIT:list>' , <EOL> mock . MagicMock ( return_value = [ ] ) ) <EOL> @ mock . patch . object ( <EOL> workflows . WorkflowManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = WF1 ) ) <EOL> @ mock . patch . object ( <EOL> workflows . WorkflowManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = [ WF1 ] ) ) <EOL> @ mock . patch . object ( <EOL> executions . ExecutionManager , '<STR_LIT:list>' , <EOL> mock . MagicMock ( return_value = [ executions . Execution ( None , WF1_EXEC ) ] ) ) <EOL> @ mock . patch . object ( <EOL> executions . ExecutionManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = executions . Execution ( None , WF1_EXEC ) ) ) <EOL> @ mock . patch . object ( <EOL> executions . ExecutionManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = executions . Execution ( None , WF1_EXEC ) ) ) <EOL> @ mock . patch . object ( <EOL> tasks . TaskManager , '<STR_LIT:list>' , <EOL> mock . MagicMock ( return_value = WF1_TASKS ) ) <EOL> def test_resume_tasks_not_in_rerunable_state ( self ) : <EOL> MistralRunner . entry_point = mock . PropertyMock ( return_value = WF1_YAML_FILE_PATH ) <EOL> liveaction1 = LiveActionDB ( action = WF1_NAME , parameters = ACTION_PARAMS ) <EOL> liveaction1 , execution1 = action_service . request ( liveaction1 ) <EOL> context = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : execution1 . id , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] <EOL> } <EOL> } <EOL> liveaction2 = LiveActionDB ( action = WF1_NAME , parameters = ACTION_PARAMS , context = context ) <EOL> liveaction2 , execution2 = action_service . request ( liveaction2 ) <EOL> liveaction2 = LiveAction . get_by_id ( str ( liveaction2 . id ) ) <EOL> self . assertEqual ( liveaction2 . status , action_constants . LIVEACTION_STATUS_FAILED ) <EOL> self . assertIn ( '<STR_LIT>' , liveaction2 . result . get ( '<STR_LIT:error>' ) ) <EOL> @ mock . patch . object ( <EOL> workflows . WorkflowManager , '<STR_LIT:list>' , <EOL> mock . MagicMock ( return_value = [ ] ) ) <EOL> @ mock . patch . object ( <EOL> workflows . WorkflowManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = WF1 ) ) <EOL> @ mock . patch . object ( <EOL> workflows . WorkflowManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = [ WF1 ] ) ) <EOL> @ mock . patch . object ( <EOL> executions . ExecutionManager , '<STR_LIT:list>' , <EOL> mock . MagicMock ( return_value = [ executions . Execution ( None , WF1_EXEC ) ] ) ) <EOL> @ mock . patch . object ( <EOL> executions . ExecutionManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = executions . Execution ( None , WF1_EXEC ) ) ) <EOL> @ mock . patch . object ( <EOL> executions . ExecutionManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = executions . Execution ( None , WF1_EXEC ) ) ) <EOL> @ mock . patch . object ( <EOL> tasks . TaskManager , '<STR_LIT:list>' , <EOL> mock . MagicMock ( return_value = WF1_TASKS ) ) <EOL> def test_resume_unidentified_tasks ( self ) : <EOL> MistralRunner . entry_point = mock . PropertyMock ( return_value = WF1_YAML_FILE_PATH ) <EOL> liveaction1 = LiveActionDB ( action = WF1_NAME , parameters = ACTION_PARAMS ) <EOL> liveaction1 , execution1 = action_service . request ( liveaction1 ) <EOL> context = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : execution1 . id , <EOL> '<STR_LIT>' : [ '<STR_LIT:x>' ] <EOL> } <EOL> } <EOL> liveaction2 = LiveActionDB ( action = WF1_NAME , parameters = ACTION_PARAMS , context = context ) <EOL> liveaction2 , execution2 = action_service . request ( liveaction2 ) <EOL> liveaction2 = LiveAction . get_by_id ( str ( liveaction2 . id ) ) <EOL> self . assertEqual ( liveaction2 . status , action_constants . LIVEACTION_STATUS_FAILED ) <EOL> self . assertIn ( '<STR_LIT>' , liveaction2 . result . get ( '<STR_LIT:error>' ) ) <EOL> @ mock . patch . object ( <EOL> workflows . WorkflowManager , '<STR_LIT:list>' , <EOL> mock . MagicMock ( return_value = [ ] ) ) <EOL> @ mock . patch . object ( <EOL> workflows . WorkflowManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = WF1 ) ) <EOL> @ mock . patch . object ( <EOL> workbooks . WorkbookManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = WB1 ) ) <EOL> @ mock . patch . object ( <EOL> executions . ExecutionManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = executions . Execution ( None , WB1_MAIN_EXEC ) ) ) <EOL> @ mock . patch . object ( <EOL> executions . ExecutionManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = executions . Execution ( None , WB1_MAIN_EXEC_ERRORED ) ) ) <EOL> @ mock . patch . object ( <EOL> executions . ExecutionManager , '<STR_LIT:list>' , <EOL> mock . MagicMock ( <EOL> return_value = [ <EOL> executions . Execution ( None , WB1_MAIN_EXEC_ERRORED ) , <EOL> executions . Execution ( None , WB1_SUB1_EXEC_ERRORED ) ] ) ) <EOL> @ mock . patch . object ( <EOL> tasks . TaskManager , '<STR_LIT:list>' , <EOL> mock . MagicMock ( side_effect = [ WB1_MAIN_TASKS , WB1_SUB1_TASKS ] ) ) <EOL> @ mock . patch . object ( <EOL> tasks . TaskManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = None ) ) <EOL> def test_resume_subworkflow_task ( self ) : <EOL> MistralRunner . entry_point = mock . PropertyMock ( return_value = WB1_YAML_FILE_PATH ) <EOL> liveaction1 = LiveActionDB ( action = WB1_NAME , parameters = ACTION_PARAMS ) <EOL> liveaction1 , execution1 = action_service . request ( liveaction1 ) <EOL> context = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : execution1 . id , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] <EOL> } <EOL> } <EOL> liveaction2 = LiveActionDB ( action = WB1_NAME , parameters = ACTION_PARAMS , context = context ) <EOL> liveaction2 , execution2 = action_service . request ( liveaction2 ) <EOL> liveaction2 = LiveAction . get_by_id ( str ( liveaction2 . id ) ) <EOL> self . assertEqual ( liveaction2 . status , action_constants . LIVEACTION_STATUS_RUNNING ) <EOL> expected_env = { <EOL> '<STR_LIT>' : str ( liveaction2 . id ) , <EOL> '<STR_LIT>' : str ( execution2 . id ) , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : context [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : str ( execution2 . id ) <EOL> } , <EOL> '<STR_LIT>' : [ ] <EOL> } <EOL> } <EOL> } , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> tasks . TaskManager . rerun . assert_called_with ( <EOL> WB1_SUB1_TASK2 [ '<STR_LIT:id>' ] , <EOL> reset = False , <EOL> env = expected_env <EOL> ) <EOL> @ mock . patch . object ( <EOL> workflows . WorkflowManager , '<STR_LIT:list>' , <EOL> mock . MagicMock ( return_value = [ ] ) ) <EOL> @ mock . patch . object ( <EOL> workflows . WorkflowManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = WF1 ) ) <EOL> @ mock . patch . object ( <EOL> workbooks . WorkbookManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = WB1 ) ) <EOL> @ mock . patch . object ( <EOL> executions . ExecutionManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = executions . Execution ( None , WB1_MAIN_EXEC ) ) ) <EOL> @ mock . patch . object ( <EOL> executions . ExecutionManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = executions . Execution ( None , WB1_MAIN_EXEC_ERRORED ) ) ) <EOL> @ mock . patch . object ( <EOL> executions . ExecutionManager , '<STR_LIT:list>' , <EOL> mock . MagicMock ( <EOL> return_value = [ <EOL> executions . Execution ( None , WB1_MAIN_EXEC_ERRORED ) , <EOL> executions . Execution ( None , WB1_SUB1_EXEC_ERRORED ) ] ) ) <EOL> @ mock . patch . object ( <EOL> tasks . TaskManager , '<STR_LIT:list>' , <EOL> mock . MagicMock ( side_effect = [ WB1_MAIN_TASKS , WB1_SUB1_TASKS ] ) ) <EOL> def test_resume_unidentified_subworkflow_task ( self ) : <EOL> MistralRunner . entry_point = mock . PropertyMock ( return_value = WB1_YAML_FILE_PATH ) <EOL> liveaction1 = LiveActionDB ( action = WB1_NAME , parameters = ACTION_PARAMS ) <EOL> liveaction1 , execution1 = action_service . request ( liveaction1 ) <EOL> context = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : execution1 . id , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] <EOL> } <EOL> } <EOL> liveaction2 = LiveActionDB ( action = WB1_NAME , parameters = ACTION_PARAMS , context = context ) <EOL> liveaction2 , execution2 = action_service . request ( liveaction2 ) <EOL> liveaction2 = LiveAction . get_by_id ( str ( liveaction2 . id ) ) <EOL> self . assertEqual ( liveaction2 . status , action_constants . LIVEACTION_STATUS_FAILED ) <EOL> self . assertIn ( '<STR_LIT>' , liveaction2 . result . get ( '<STR_LIT:error>' ) ) <EOL> @ mock . patch . object ( <EOL> workflows . WorkflowManager , '<STR_LIT:list>' , <EOL> mock . MagicMock ( return_value = [ ] ) ) <EOL> @ mock . patch . object ( <EOL> workflows . WorkflowManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = WF1 ) ) <EOL> @ mock . patch . object ( <EOL> workbooks . WorkbookManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = WB1 ) ) <EOL> @ mock . patch . object ( <EOL> executions . ExecutionManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = executions . Execution ( None , WB1_MAIN_EXEC ) ) ) <EOL> @ mock . patch . object ( <EOL> executions . ExecutionManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = executions . Execution ( None , WB1_MAIN_EXEC_ERRORED ) ) ) <EOL> @ mock . patch . object ( <EOL> executions . ExecutionManager , '<STR_LIT:list>' , <EOL> mock . MagicMock ( <EOL> return_value = [ <EOL> executions . Execution ( None , WB1_MAIN_EXEC_ERRORED ) , <EOL> executions . Execution ( None , WB1_SUB1_EXEC_ERRORED ) ] ) ) <EOL> @ mock . patch . object ( <EOL> tasks . TaskManager , '<STR_LIT:list>' , <EOL> mock . MagicMock ( side_effect = [ WB1_MAIN_TASKS , WB1_SUB1_TASKS ] ) ) <EOL> @ mock . patch . object ( <EOL> tasks . TaskManager , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = None ) ) <EOL> def test_resume_and_reset_subworkflow_task ( self ) : <EOL> MistralRunner . entry_point = mock . PropertyMock ( return_value = WB1_YAML_FILE_PATH ) <EOL> liveaction1 = LiveActionDB ( action = WB1_NAME , parameters = ACTION_PARAMS ) <EOL> liveaction1 , execution1 = action_service . request ( liveaction1 ) <EOL> context = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : execution1 . id , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] <EOL> } <EOL> } <EOL> liveaction2 = LiveActionDB ( action = WB1_NAME , parameters = ACTION_PARAMS , context = context ) <EOL> liveaction2 , execution2 = action_service . request ( liveaction2 ) <EOL> liveaction2 = LiveAction . get_by_id ( str ( liveaction2 . id ) ) <EOL> self . assertEqual ( liveaction2 . status , action_constants . LIVEACTION_STATUS_RUNNING ) <EOL> expected_env = { <EOL> '<STR_LIT>' : str ( liveaction2 . id ) , <EOL> '<STR_LIT>' : str ( execution2 . id ) , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : context [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : str ( execution2 . id ) <EOL> } , <EOL> '<STR_LIT>' : [ ] <EOL> } <EOL> } <EOL> } , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> tasks . TaskManager . rerun . assert_called_with ( <EOL> WB1_SUB1_TASK2 [ '<STR_LIT:id>' ] , <EOL> reset = True , <EOL> env = expected_env <EOL> ) </s>
