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


Python FSM._run方法代码示例

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


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

示例1: test__run

# 需要导入模块: from recore.fsm import FSM [as 别名]
# 或者: from recore.fsm.FSM import _run [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_step_notification_started_no_notifications

# 需要导入模块: from recore.fsm import FSM [as 别名]
# 或者: from recore.fsm.FSM import _run [as 别名]
    def test_step_notification_started_no_notifications(self, send_notification, on_started, dequeue_step, setup):
        """Per-step notifications don't happen if no notifications are defined"""
        f = FSM(state_id)

        msg_started = {'status': 'started'}

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

        # 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)
        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()

        # Run the method now. It should terminate when it reaches the
        # end of _run() with a call to a mocked out on_started()
        with mock.patch('recore.amqp.MQ_CONF') as mq_conf:
            mq_conf = MQ_CONF
            f._run()

        self.assertEqual(send_notification.call_count, 0)
开发者ID:cooktheryan,项目名称:re-core,代码行数:35,代码来源:test_fsm.py

示例3: test__run

# 需要导入模块: from recore.fsm import FSM [as 别名]
# 或者: from recore.fsm.FSM import _run [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.group = "mock tests"
        f.dynamic = {}
        f.active_step = _active_step_string
        f.active_sequence = new_active_sequence()
        f.execution = new_playbook()['execution']

        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

        with mock.patch('recore.amqp.MQ_CONF') as mq_conf:
            mq_conf = MQ_CONF
            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:cooktheryan,项目名称:re-core,代码行数:34,代码来源:test_fsm.py

示例4: test_step_notification_started_two_transports

# 需要导入模块: from recore.fsm import FSM [as 别名]
# 或者: from recore.fsm.FSM import _run [as 别名]
    def test_step_notification_started_two_transports(self, send_notification, on_started, dequeue_step, setup):
        """Per-step notifications happen for all defined transports

Tests for the case where multiple notification transports (irc, email, etc) are defined"""

        f = FSM(TEST_PBID, state_id)

        msg_started = {'status': 'started'}

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

        # 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)
        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 = {}

        _step = {
            "service:Restart": {
                "service": "megafrobber",
                "notify": {
                    "started": {
                        "irc": ['#achannel'],
                        "email": ['[email protected]']
                    }
                }
            }
        }

        f.active_step = _step

        # Run the method now. It should terminate when it reaches the
        # end of _run() with a call to a mocked out on_started()
        with mock.patch('recore.amqp.MQ_CONF') as mq_conf:
            mq_conf = MQ_CONF
            set_field = mock.MagicMock()
            filter = mock.MagicMock(return_value=set_field)
            f.filter = filter
            f._run()

        self.assertEqual(send_notification.call_count, 2)
开发者ID:RHInception,项目名称:re-core,代码行数:54,代码来源:test_fsm.py

示例5: test__run_finished

# 需要导入模块: from recore.fsm import FSM [as 别名]
# 或者: from recore.fsm.FSM import _run [as 别名]
 def test__run_finished(self, setup, cleanup):
     """When the FSM is out of steps it raises IndexError and calls _cleanup"""
     f = FSM(state_id)
     result = f._run()
     f._setup.assert_called_once_with()
     f.dequeue_next_active_step.assert_called_once_with()
     cleanup.assert_called_once_with()
     self.assertTrue(result)
开发者ID:Acidburn0zzz,项目名称:re-core,代码行数:10,代码来源:test_fsm.py

示例6: test_step_notification_started

# 需要导入模块: from recore.fsm import FSM [as 别名]
# 或者: from recore.fsm.FSM import _run [as 别名]
    def test_step_notification_started(self, send_notification, on_started, dequeue_step, setup):
        """Per-step notifications work when starting a step

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

        msg_started = {'status': 'started'}

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

        # 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)
        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('started')

        # Run the method now. It should terminate when it reaches the
        # end of _run() with a call to a mocked out on_started()
        with mock.patch('recore.amqp.MQ_CONF') as mq_conf:
            mq_conf = MQ_CONF
            set_field = mock.MagicMock()
            filter = mock.MagicMock(return_value=set_field)
            f.filter = filter
            f._run()

        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], 'started')
开发者ID:RHInception,项目名称:re-core,代码行数:44,代码来源:test_fsm.py


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