@patch('st2actions.runners.ssh.parallel_ssh.ParallelSSHClient', Mock)
    @patch.object(ParallelSSHClient, 'run', MagicMock(return_value={}))
    @patch.object(ParallelSSHClient, 'connect', MagicMock(return_value={}))
    def test_top_level_error_is_correctly_reported(self):
        # Verify that a top-level error doesn't cause an exception to be thrown.
        # In a top-level error case, result dict doesn't contain entry per host
        paramiko_runner = ParamikoRemoteScriptRunner('runner_1')

        paramiko_runner.runner_parameters = {
            'username': 'test_user',
            'hosts': '127.0.0.1'
        }
        paramiko_runner.action = ACTION_1
        paramiko_runner.liveaction_id = 'foo'
        paramiko_runner.entry_point = 'foo'
        paramiko_runner.context = {}
        paramiko_runner._cwd = '/tmp'
        paramiko_runner._copy_artifacts = Mock(side_effect=Exception('fail!'))
        status, result, _ = paramiko_runner.run(action_parameters={})

        self.assertEqual(status, LIVEACTION_STATUS_FAILED)
        self.assertEqual(result['failed'], True)
        self.assertEqual(result['succeeded'], False)
        self.assertTrue('Failed copying content to remote boxes' in result['error'])
dataset/ETHPy150Open StackStorm/st2/st2actions/tests/unit/test_paramiko_remote_script_runner.py/ParamikoScriptRunnerTestCase.test_top_level_error_is_correctly_reported/original