当前位置: 首页>>代码示例>>Python>>正文


Python FSM.executed方法代码示例

本文整理汇总了Python中recore.fsm.FSM.executed方法的典型用法代码示例。如果您正苦于以下问题:Python FSM.executed方法的具体用法?Python FSM.executed怎么用?Python FSM.executed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在recore.fsm.FSM的用法示例。


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

示例1: test_dequeue_next_active_step

# 需要导入模块: from recore.fsm import FSM [as 别名]
# 或者: from recore.fsm.FSM import executed [as 别名]
    def test_dequeue_next_active_step(self):
        """The FSM can remove the next step and update Mongo with it"""
        f = FSM(TEST_PBID, state_id)
        f.active_step = _active_step_string
        f.active_sequence = new_active_sequence()
        f.executed = []
        f.execution = new_playbook()['execution']

        _update_state = {
            '$set': {
                'active_step': _active_step_string,
                'active_sequence': f.active_sequence,
                'executed': [],
                'execution': new_playbook()['execution'],
            }
        }

        with mock.patch.object(f, 'update_state') as (
                us):
            set_field = mock.MagicMock()
            filter = mock.MagicMock(return_value=set_field)
            f.filter = filter
            f.dequeue_next_active_step()
            us.assert_called_once_with(_update_state)
            self.assertEqual(f.active_step, _active_step_string)
开发者ID:RHInception,项目名称:re-core,代码行数:27,代码来源:test_fsm.py

示例2: test_step_notification_failed

# 需要导入模块: from recore.fsm import FSM [as 别名]
# 或者: from recore.fsm.FSM import executed [as 别名]
    def test_step_notification_failed(self, send_notification, move_remaining, setup, updatestate):
        """Per-step notifications work when a step fails

Tests for the case where only one notification transport (irc, email, etc) is defined"""
        f = FSM(TEST_PBID, state_id)

        msg_failed = {'status': 'failed'}

        consume_iter = [
            (mock.Mock(name="method_mocked"),
             mock.Mock(name="properties_mocked"),
             json.dumps(msg_failed))
        ]

        # Pre-test scaffolding. Hard-code some mocked out
        # attributes/variables because we're skipping the usual
        # initialization steps.
        f.conn = mock.Mock(pika.connection.Connection)
        f.executed = []
        f.execution = []
        f.state_coll = {}
        f.post_deploy_action = []
        publish = mock.Mock()
        channel = mock.Mock()
        channel.consume.return_value = iter(consume_iter)
        channel.basic_publish = publish
        f.ch = channel
        f.active_sequence = {'hosts': ['localhost']}
        f.group = 'testgroup'
        f.dynamic = {}
        f.active_step = new_notify_step('failed')
        set_field = mock.MagicMock()
        filter = mock.MagicMock(return_value=set_field)
        f.filter = filter

        # Run the ended method with a body having 'status' as failed
        f.on_ended(channel,
                   mock.Mock(name="method_mocked"),
                   mock.Mock(name="header_mocked"),
                   json.dumps(msg_failed))

        self.assertEqual(send_notification.call_count, 1)
        self.assertEqual(send_notification.call_args[0][1], 'notify.irc')
        self.assertEqual(send_notification.call_args[0][2], state_id)
        self.assertEqual(send_notification.call_args[0][3], ['#achannel'])
        self.assertEqual(send_notification.call_args[0][4], 'failed')
开发者ID:RHInception,项目名称:re-core,代码行数:48,代码来源:test_fsm.py

示例3: test_move_active_to_completed

# 需要导入模块: from recore.fsm import FSM [as 别名]
# 或者: from recore.fsm.FSM import executed [as 别名]
    def test_move_active_to_completed(self):
        """FSM can update after completing a step"""
        f = FSM(state_id)
        f.active_step = _active_step_string
        f.active_sequence = new_active_sequence()
        f.active_sequence['completed_steps'] = []
        f.executed = []
        f.execution = new_playbook()['execution']
        f.completed_steps = []

        # For .called_once_with()
        _update_state = {
            '$set': {
                'active_step': None,
                'active_sequence': f.active_sequence
            }
        }

        with mock.patch.object(f, 'update_state') as (us):
            f.move_active_to_completed()
            us.assert_called_once_with(_update_state)
开发者ID:cooktheryan,项目名称:re-core,代码行数:23,代码来源:test_fsm.py


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