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


Python FSM.active方法代码示例

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


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

示例1: test__run

# 需要导入模块: from recore.fsm import FSM [as 别名]
# 或者: from recore.fsm.FSM import active [as 别名]
    def test__run(self, setup, dequeue, on_started):
        """The _run() method can send a proper message to a worker"""
        f = FSM(state_id)
        f.reply_queue = temp_queue

        f.project = "mock tests"
        f.dynamic = {}
        f.active = {
            'plugin': 'fake',
            'parameters': {'no': 'parameters'}
        }
        consume_iter = [
            (mock.Mock(name="method_mocked"),
             mock.Mock(name="properties_mocked"),
             json.dumps(msg_completed))
         ]

        publish = mock.Mock()
        channel = mock.Mock()
        channel.consume.return_value = iter(consume_iter)
        channel.basic_publish = publish
        f.ch = channel

        f._run()

        setup.assert_called_once_with()
        dequeue.assert_called_once_with()
        f.ch.basic_ack.assert_called_once_with(consume_iter[0][0].delivery_tag)
        f.ch.cancel.assert_called_once_with()
        on_started.assert_called_once_with(f.ch, *consume_iter[0])
开发者ID:Acidburn0zzz,项目名称:re-core,代码行数:32,代码来源:test_fsm.py

示例2: test_move_active_to_completed

# 需要导入模块: from recore.fsm import FSM [as 别名]
# 或者: from recore.fsm.FSM import active [as 别名]
    def test_move_active_to_completed(self):
        """FSM can update after completing a step"""
        f = FSM(state_id)
        active_step = {"plugin": "not real"}
        f.active = active_step.copy()
        f.completed = []

        # For .called_once_with()
        _update_state = {
            '$set': {
                'active_step': None,
                'completed_steps': [active_step]
            }
        }

        with mock.patch.object(f, 'update_state') as (us):
            f.move_active_to_completed()
            us.assert_called_once_with(_update_state)
            self.assertEqual(f.active, None)
            self.assertEqual(f.completed, [active_step])
开发者ID:Acidburn0zzz,项目名称:re-core,代码行数:22,代码来源:test_fsm.py


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