• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python actionchainrunner.get_runner函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中st2actions.runners.actionchainrunner.get_runner函数的典型用法代码示例。如果您正苦于以下问题:Python get_runner函数的具体用法?Python get_runner怎么用?Python get_runner使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_runner函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_chain_runner_task_is_canceled_while_running

    def test_chain_runner_task_is_canceled_while_running(self, request):
        # Second task in the action is CANCELED, make sure runner doesn't get stuck in an infinite
        # loop
        chain_runner = acr.get_runner()
        chain_runner.entry_point = CHAIN_2_PATH
        chain_runner.action = ACTION_1

        original_run_action = chain_runner._run_action

        def mock_run_action(*args, **kwargs):
            original_live_action = args[0]
            if original_live_action.action == 'wolfpack.a2':
                status = LIVEACTION_STATUS_CANCELED
            else:
                status = LIVEACTION_STATUS_SUCCEEDED
            request.return_value = (DummyActionExecution(status=status), None)
            liveaction = original_run_action(*args, **kwargs)
            return liveaction

        chain_runner._run_action = mock_run_action

        action_ref = ResourceReference.to_string_reference(name=ACTION_1.name,
                                                           pack=ACTION_1.pack)
        chain_runner.liveaction = LiveActionDB(action=action_ref)
        chain_runner.container_service = RunnerContainerService()
        chain_runner.pre_run()
        status, _, _ = chain_runner.run({})

        self.assertEqual(status, LIVEACTION_STATUS_CANCELED)
        self.assertNotEqual(chain_runner.chain_holder.actionchain, None)
        # Chain count should be 2 since the last task doesn't get called since the second one was
        # canceled
        self.assertEqual(request.call_count, 2)
开发者ID:logikal,项目名称:st2,代码行数:33,代码来源:test_actionchain.py


示例2: test_chain_runner_chain_second_task_times_out

    def test_chain_runner_chain_second_task_times_out(self, request):
        # Second task in the chain times out so the action chain status should be timeout
        chain_runner = acr.get_runner()
        chain_runner.entry_point = CHAIN_2_PATH
        chain_runner.action = ACTION_1

        original_run_action = chain_runner._run_action

        def mock_run_action(*args, **kwargs):
            original_live_action = args[0]
            liveaction = original_run_action(*args, **kwargs)
            if original_live_action.action == 'wolfpack.a2':
                # Mock a timeout for second task
                liveaction.status = LIVEACTION_STATUS_TIMED_OUT
            return liveaction

        chain_runner._run_action = mock_run_action

        action_ref = ResourceReference.to_string_reference(name=ACTION_1.name,
                                                           pack=ACTION_1.pack)
        chain_runner.liveaction = LiveActionDB(action=action_ref)
        chain_runner.container_service = RunnerContainerService()
        chain_runner.pre_run()
        status, _, _ = chain_runner.run({})

        self.assertEqual(status, LIVEACTION_STATUS_TIMED_OUT)
        self.assertNotEqual(chain_runner.chain_holder.actionchain, None)
        # based on the chain the callcount is known to be 3. Not great but works.
        self.assertEqual(request.call_count, 3)
开发者ID:logikal,项目名称:st2,代码行数:29,代码来源:test_actionchain.py


示例3: test_chain_runner_bad_default

 def test_chain_runner_bad_default(self, request):
     chain_runner = acr.get_runner()
     chain_runner.entry_point = CHAIN_BAD_DEFAULT
     chain_runner.action = ACTION_1
     chain_runner.container_service = RunnerContainerService()
     expected_msg = 'Unable to find node with name "bad_default" referenced in "default".'
     self.assertRaisesRegexp(runnerexceptions.ActionRunnerPreRunError,
                             expected_msg, chain_runner.pre_run)
开发者ID:logikal,项目名称:st2,代码行数:8,代码来源:test_actionchain.py


示例4: test_chain_runner_missing_param_temp

 def test_chain_runner_missing_param_temp(self, schedule):
     chain_runner = acr.get_runner()
     chain_runner.entry_point = CHAIN_STR_TEMP_PATH
     chain_runner.action = ACTION_1
     chain_runner.container_service = RunnerContainerService()
     chain_runner.pre_run()
     chain_runner.run({})
     self.assertEqual(schedule.call_count, 0, 'No call expected.')
开发者ID:bjoernbessert,项目名称:st2,代码行数:8,代码来源:test_actionchain.py


示例5: test_chain_runner_missing_param_temp

 def test_chain_runner_missing_param_temp(self, request):
     chain_runner = acr.get_runner()
     chain_runner.entry_point = CHAIN_FIRST_TASK_RENDER_FAIL_PATH
     chain_runner.action = ACTION_1
     chain_runner.container_service = RunnerContainerService()
     chain_runner.pre_run()
     chain_runner.run({})
     self.assertEqual(request.call_count, 0, 'No call expected.')
开发者ID:amaline,项目名称:st2,代码行数:8,代码来源:test_actionchain.py


示例6: test_chain_runner_str_param_temp

 def test_chain_runner_str_param_temp(self, schedule):
     chain_runner = acr.get_runner()
     chain_runner.entry_point = CHAIN_FIRST_TASK_RENDER_FAIL_PATH
     chain_runner.action = ACTION_1
     chain_runner.container_service = RunnerContainerService()
     chain_runner.pre_run()
     chain_runner.run({'s1': 1, 's2': 2, 's3': 3, 's4': 4})
     self.assertNotEqual(chain_runner.chain_holder.actionchain, None)
     mock_args, _ = schedule.call_args
     self.assertEqual(mock_args[0].parameters, {"p1": "1"})
开发者ID:BlazeMediaGroup,项目名称:st2,代码行数:10,代码来源:test_actionchain.py


示例7: test_chain_runner_action_exception

 def test_chain_runner_action_exception(self, schedule):
     chain_runner = acr.get_runner()
     chain_runner.entry_point = CHAIN_1_PATH
     chain_runner.action = ACTION_1
     chain_runner.container_service = RunnerContainerService()
     chain_runner.pre_run()
     chain_runner.run({})
     self.assertNotEqual(chain_runner.action_chain, None)
     # based on the chain the callcount is known to be 2. Not great but works.
     self.assertEqual(schedule.call_count, 2)
开发者ID:bjoernbessert,项目名称:st2,代码行数:10,代码来源:test_actionchain.py


示例8: test_malformed_chain

 def test_malformed_chain(self):
     try:
         chain_runner = acr.get_runner()
         chain_runner.entry_point = MALFORMED_CHAIN_PATH
         chain_runner.action = ACTION_1
         chain_runner.container_service = RunnerContainerService()
         chain_runner.pre_run()
         self.assertTrue(False, 'Expected pre_run to fail.')
     except runnerexceptions.ActionRunnerPreRunError:
         self.assertTrue(True)
开发者ID:amaline,项目名称:st2,代码行数:10,代码来源:test_actionchain.py


示例9: test_chain_runner_success_path_with_wait

 def test_chain_runner_success_path_with_wait(self, schedule):
     chain_runner = acr.get_runner()
     chain_runner.entry_point = CHAIN_1_PATH
     chain_runner.action = DummyAction()
     chain_runner.container_service = RunnerContainerService()
     chain_runner.pre_run()
     chain_runner.run({})
     self.assertNotEqual(chain_runner.action_chain, None)
     # based on the chain the callcount is known to be 3. Not great but works.
     self.assertEqual(schedule.call_count, 3)
开发者ID:gitter-badger,项目名称:st2,代码行数:10,代码来源:test_actionchain.py


示例10: test_chain_runner_list_param_temp

 def test_chain_runner_list_param_temp(self, request):
     chain_runner = acr.get_runner()
     chain_runner.entry_point = CHAIN_LIST_TEMP_PATH
     chain_runner.action = ACTION_1
     chain_runner.container_service = RunnerContainerService()
     chain_runner.pre_run()
     chain_runner.run({'s1': 1, 's2': 2, 's3': 3, 's4': 4})
     self.assertNotEqual(chain_runner.chain_holder.actionchain, None)
     mock_args, _ = request.call_args
     self.assertEqual(mock_args[0].parameters, {"p1": "[2, 3, 4]"})
开发者ID:amaline,项目名称:st2,代码行数:10,代码来源:test_actionchain.py


示例11: test_exception_is_thrown_if_both_params_and_parameters_attributes_are_provided

    def test_exception_is_thrown_if_both_params_and_parameters_attributes_are_provided(self):
        chain_runner = acr.get_runner()
        chain_runner.entry_point = CHAIN_ACTION_PARAMS_AND_PARAMETERS_ATTRIBUTE
        chain_runner.action = ACTION_2
        chain_runner.container_service = RunnerContainerService()

        expected_msg = ('Either "params" or "parameters" attribute needs to be provided, but '
                       'not both')
        self.assertRaisesRegexp(runnerexceptions.ActionRunnerPreRunError, expected_msg,
                                chain_runner.pre_run)
开发者ID:logikal,项目名称:st2,代码行数:10,代码来源:test_actionchain.py


示例12: test_chain_runner_str_param_temp

 def test_chain_runner_str_param_temp(self, schedule):
     chain_runner = acr.get_runner()
     chain_runner.entry_point = CHAIN_STR_TEMP_PATH
     chain_runner.action = DummyAction()
     chain_runner.container_service = RunnerContainerService()
     chain_runner.pre_run()
     chain_runner.run({'s1': 1, 's2': 2, 's3': 3, 's4': 4})
     self.assertNotEqual(chain_runner.action_chain, None)
     mock_args, _ = schedule.call_args
     self.assertEqual(mock_args[0].parameters, {"p1": "1"})
开发者ID:gitter-badger,项目名称:st2,代码行数:10,代码来源:test_actionchain.py


示例13: test_chain_runner_broken_on_failure_path_static_task_name

    def test_chain_runner_broken_on_failure_path_static_task_name(self, request):
        chain_runner = acr.get_runner()
        chain_runner.entry_point = CHAIN_BROKEN_ON_FAILURE_PATH_STATIC_TASK_NAME
        chain_runner.action = ACTION_1
        chain_runner.container_service = RunnerContainerService()

        expected_msg = ('Unable to find node with name "c6" referenced in "on-failure" '
                        'in task "c2"')
        self.assertRaisesRegexp(runnerexceptions.ActionRunnerPreRunError,
                                expected_msg, chain_runner.pre_run)
开发者ID:logikal,项目名称:st2,代码行数:10,代码来源:test_actionchain.py


示例14: test_chain_runner_success_path_with_wait

 def test_chain_runner_success_path_with_wait(self, request):
     chain_runner = acr.get_runner()
     chain_runner.entry_point = CHAIN_1_PATH
     chain_runner.action = ACTION_1
     chain_runner.container_service = RunnerContainerService()
     chain_runner.pre_run()
     chain_runner.run({})
     self.assertNotEqual(chain_runner.chain_holder.actionchain, None)
     # based on the chain the callcount is known to be 3. Not great but works.
     self.assertEqual(request.call_count, 3)
开发者ID:amaline,项目名称:st2,代码行数:10,代码来源:test_actionchain.py


示例15: test_params_and_parameters_attributes_both_work

    def test_params_and_parameters_attributes_both_work(self, _):
        # "params" attribute used
        chain_runner = acr.get_runner()
        chain_runner.entry_point = CHAIN_ACTION_PARAMS_ATTRIBUTE
        chain_runner.action = ACTION_2
        chain_runner.container_service = RunnerContainerService()
        chain_runner.pre_run()

        original_build_liveaction_object = chain_runner._build_liveaction_object

        def mock_build_liveaction_object(action_node, resolved_params, parent_context):
            # Verify parameters are correctly passed to the action
            self.assertEqual(resolved_params, {'pparams': 'v1'})
            original_build_liveaction_object(action_node=action_node,
                                             resolved_params=resolved_params,
                                             parent_context=parent_context)

        chain_runner._build_liveaction_object = mock_build_liveaction_object

        action_parameters = {}
        status, output, _ = chain_runner.run(action_parameters=action_parameters)
        self.assertEqual(status, LIVEACTION_STATUS_SUCCEEDED)

        # "parameters" attribute used
        chain_runner = acr.get_runner()
        chain_runner.entry_point = CHAIN_ACTION_PARAMETERS_ATTRIBUTE
        chain_runner.action = ACTION_2
        chain_runner.container_service = RunnerContainerService()
        chain_runner.pre_run()

        def mock_build_liveaction_object(action_node, resolved_params, parent_context):
            # Verify parameters are correctly passed to the action
            self.assertEqual(resolved_params, {'pparameters': 'v1'})
            original_build_liveaction_object(action_node=action_node,
                                             resolved_params=resolved_params,
                                             parent_context=parent_context)

        chain_runner._build_liveaction_object = mock_build_liveaction_object

        action_parameters = {}
        status, output, _ = chain_runner.run(action_parameters=action_parameters)
        self.assertEqual(status, LIVEACTION_STATUS_SUCCEEDED)
开发者ID:logikal,项目名称:st2,代码行数:42,代码来源:test_actionchain.py


示例16: test_chain_runner_dict_param_temp

 def test_chain_runner_dict_param_temp(self, request):
     chain_runner = acr.get_runner()
     chain_runner.entry_point = CHAIN_DICT_TEMP_PATH
     chain_runner.action = ACTION_1
     chain_runner.container_service = RunnerContainerService()
     chain_runner.pre_run()
     chain_runner.run({'s1': 1, 's2': 2, 's3': 3, 's4': 4})
     self.assertNotEqual(chain_runner.chain_holder.actionchain, None)
     expected_value = {"p1": {"p1.3": "[3, 4]", "p1.2": "2", "p1.1": "1"}}
     mock_args, _ = request.call_args
     self.assertEqual(mock_args[0].parameters, expected_value)
开发者ID:amaline,项目名称:st2,代码行数:11,代码来源:test_actionchain.py


示例17: test_chain_runner_failure_path

 def test_chain_runner_failure_path(self, request):
     chain_runner = acr.get_runner()
     chain_runner.entry_point = CHAIN_1_PATH
     chain_runner.action = ACTION_1
     chain_runner.container_service = RunnerContainerService()
     chain_runner.pre_run()
     status, _, _ = chain_runner.run({})
     self.assertEqual(status, LIVEACTION_STATUS_FAILED)
     self.assertNotEqual(chain_runner.chain_holder.actionchain, None)
     # based on the chain the callcount is known to be 2. Not great but works.
     self.assertEqual(request.call_count, 2)
开发者ID:amaline,项目名称:st2,代码行数:11,代码来源:test_actionchain.py


示例18: test_chain_task_passes_invalid_parameter_type_to_action

    def test_chain_task_passes_invalid_parameter_type_to_action(self, mock_request):
        chain_runner = acr.get_runner()
        chain_runner.entry_point = CHAIN_ACTION_INVALID_PARAMETER_TYPE
        chain_runner.action = ACTION_2
        chain_runner.container_service = RunnerContainerService()
        chain_runner.pre_run()

        action_parameters = {}
        expected_msg = ('Failed to cast value "stringnotanarray" for parameter '
                        '"arrtype" of type "array"')
        self.assertRaisesRegexp(ValueError, expected_msg, chain_runner.run,
                                action_parameters=action_parameters)
开发者ID:AlexeyDeyneko,项目名称:st2,代码行数:12,代码来源:test_actionchain.py


示例19: test_chain_runner_failure_path

 def test_chain_runner_failure_path(self, schedule):
     chain_runner = acr.get_runner()
     chain_runner.entry_point = CHAIN_1_PATH
     chain_runner.action = ACTION_1
     chain_runner.container_service = RunnerContainerService()
     chain_runner.pre_run()
     success = chain_runner.run({})
     self.assertFalse(success)
     self.assertEqual(chain_runner.container_service.get_status(),
                      ACTIONEXEC_STATUS_FAILED)
     self.assertNotEqual(chain_runner.action_chain, None)
     # based on the chain the callcount is known to be 2. Not great but works.
     self.assertEqual(schedule.call_count, 2)
开发者ID:bjoernbessert,项目名称:st2,代码行数:13,代码来源:test_actionchain.py


示例20: test_chain_runner_vars_action_params

 def test_chain_runner_vars_action_params(self, request):
     chain_runner = acr.get_runner()
     chain_runner.entry_point = CHAIN_WITH_ACTIONPARAM_VARS
     chain_runner.action = ACTION_2
     chain_runner.container_service = RunnerContainerService()
     chain_runner.pre_run()
     chain_runner.run({'input_a': 'two'})
     self.assertNotEqual(chain_runner.chain_holder.actionchain, None)
     expected_value = {'inttype': 1,
                       'strtype': 'two',
                       'booltype': True}
     mock_args, _ = request.call_args
     self.assertEqual(mock_args[0].parameters, expected_value)
开发者ID:amaline,项目名称:st2,代码行数:13,代码来源:test_actionchain.py



注:本文中的st2actions.runners.actionchainrunner.get_runner函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pythonrunner.get_runner函数代码示例发布时间:2022-05-27
下一篇:
Python mistral.MistralCallbackHandler类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap