<s> import mock <EOL> from st2actions . runners import actionchainrunner as acr <EOL> from st2actions . container . service import RunnerContainerService <EOL> from st2common . constants . action import LIVEACTION_STATUS_SUCCEEDED <EOL> from st2common . services import action as action_service <EOL> from st2common . util import action_db as action_db_util <EOL> from st2tests import DbTestCase <EOL> from st2tests . fixturesloader import FixturesLoader <EOL> class DummyActionExecution ( object ) : <EOL> def __init__ ( self , status = LIVEACTION_STATUS_SUCCEEDED , result = '<STR_LIT>' ) : <EOL> self . id = None <EOL> self . status = status <EOL> self . result = result <EOL> FIXTURES_PACK = '<STR_LIT>' <EOL> TEST_MODELS = { <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] <EOL> } <EOL> MODELS = FixturesLoader ( ) . load_models ( fixtures_pack = FIXTURES_PACK , <EOL> fixtures_dict = TEST_MODELS ) <EOL> ACTION_1 = MODELS [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> ACTION_2 = MODELS [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> RUNNER = MODELS [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> CHAIN_1_PATH = FixturesLoader ( ) . get_fixture_file_path_abs ( <EOL> FIXTURES_PACK , '<STR_LIT>' , '<STR_LIT>' ) <EOL> @ mock . patch . object ( action_db_util , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = RUNNER ) ) <EOL> class TestActionChainNotifications ( DbTestCase ) : <EOL> @ mock . patch . object ( action_db_util , '<STR_LIT>' , <EOL> mock . MagicMock ( return_value = ACTION_1 ) ) <EOL> @ mock . patch . object ( action_service , '<STR_LIT>' , return_value = ( DummyActionExecution ( ) , None ) ) <EOL> def test_chain_runner_success_path ( self , request ) : <EOL> chain_runner = acr . get_runner ( ) <EOL> chain_runner . entry_point = CHAIN_1_PATH <EOL> chain_runner . action = ACTION_1 <EOL> chain_runner . container_service = RunnerContainerService ( ) <EOL> chain_runner . pre_run ( ) <EOL> chain_runner . run ( { } ) <EOL> self . assertNotEqual ( chain_runner . chain_holder . actionchain , None ) <EOL> self . assertEqual ( request . call_count , <NUM_LIT:2> ) <EOL> first_call_args = request . call_args_list [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] <EOL> liveaction_db = first_call_args [ <NUM_LIT:0> ] <EOL> self . assertTrue ( liveaction_db . notify , '<STR_LIT>' ) <EOL> second_call_args = request . call_args_list [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] <EOL> liveaction_db = second_call_args [ <NUM_LIT:0> ] <EOL> self . assertFalse ( liveaction_db . notify , '<STR_LIT>' ) </s>
