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


Python FSM._connect_mq方法代码示例

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


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

示例1: test__connect_mq

# 需要导入模块: from recore.fsm import FSM [as 别名]
# 或者: from recore.fsm.FSM import _connect_mq [as 别名]
    def test__connect_mq(self, connection, channel, creds):
        """FSM connecting to AMQP sets its reply_queue attribute"""
        with mock.patch.dict('recore.fsm.recore.amqp.MQ_CONF', MQ_CONF):
            creds.return_value = mock.MagicMock(spec=pika.credentials.PlainCredentials, name="mocked creds")
            mocked_conn = mock.MagicMock(spec=pika.connection.Connection, name="mocked connection")
            mocked_channel = mock.MagicMock(spec=pika.channel.Channel, name="mocked channel")
            channel.return_value = mocked_channel
            channel.queue_declare.return_value.method.queue = temp_queue
            mocked_conn.channel.return_value = channel
            connection.return_value = mocked_conn

            f = FSM(TEST_PBID, state_id)
            (ch, conn) = f._connect_mq()
            self.assertEqual(f.reply_queue, temp_queue, msg="Expected %s for reply_queue, instead got %s" %
                             (temp_queue, f.reply_queue))
开发者ID:RHInception,项目名称:re-core,代码行数:17,代码来源:test_fsm.py

示例2: test__setup_amqp_connect_fails

# 需要导入模块: from recore.fsm import FSM [as 别名]
# 或者: from recore.fsm.FSM import _connect_mq [as 别名]
    def test__setup_amqp_connect_fails(self):
        """_setup raises exception if amqp connection can't be made"""
        f = FSM(state_id)
        f._connect_mq = mock.MagicMock(side_effect=pika.exceptions.AMQPError("Couldn't connect to AMQP"))

        with mock.patch('recore.mongo.database') as (
                mongo.database):
            mongo.database = mock.MagicMock(pymongo.database.Database)
            mongo.database.__getitem__.return_value = mock.MagicMock(pymongo.collection.Collection)

            with mock.patch('recore.mongo.lookup_state') as (
                    mongo.lookup_state):
                # Found the state document in MongoDB
                mongo.lookup_state.return_value = _state

                with self.assertRaises(pika.exceptions.AMQPError):
                    f._setup()
开发者ID:Acidburn0zzz,项目名称:re-core,代码行数:19,代码来源:test_fsm.py

示例3: test__setup

# 需要导入模块: from recore.fsm import FSM [as 别名]
# 或者: from recore.fsm.FSM import _connect_mq [as 别名]
    def test__setup(self):
        """Setup works with an existing state document"""
        f = FSM(state_id)
        # An AMQP connection hasn't been made yet
        f._connect_mq = mock.MagicMock(return_value=(mock.Mock(pika.channel.Channel),
                                      mock.Mock(pika.connection.Connection)))

        with mock.patch('recore.mongo.database') as (
                mongo.database):
            mongo.database = mock.MagicMock(pymongo.database.Database)
            mongo.database.__getitem__.return_value = mock.MagicMock(pymongo.collection.Collection)

            with mock.patch('recore.mongo.lookup_state') as (
                    mongo.lookup_state):
                mongo.lookup_state.return_value = _state

                f._setup()
                assert f.project == _state['project']
开发者ID:Acidburn0zzz,项目名称:re-core,代码行数:20,代码来源:test_fsm.py

示例4: test__connect_mq

# 需要导入模块: from recore.fsm import FSM [as 别名]
# 或者: from recore.fsm.FSM import _connect_mq [as 别名]
    def test__connect_mq(self, mq_conf, connection, channel, creds):
        """FSM connecting to AMQP sets its reply_queue attribute"""
        mq_conf = {
            'NAME': 'user',
            'PASSWORD': 'pass',
            'SERVER': '127.0.0.1',
            'EXCHANGE': 'foochange'
        }
        creds.return_value = mock.MagicMock(spec=pika.credentials.PlainCredentials, name="mocked creds")
        mocked_conn = mock.MagicMock(spec=pika.connection.Connection, name="mocked connection")
        mocked_channel = mock.MagicMock(spec=pika.channel.Channel, name="mocked channel")
        channel.return_value = mocked_channel
        channel.queue_declare.return_value.method.queue = temp_queue
        mocked_conn.channel.return_value = channel
        connection.return_value = mocked_conn

        f = FSM(state_id)
        (ch, conn) = f._connect_mq()
        self.assertEqual(f.reply_queue, temp_queue, msg="Expected %s for reply_queue, instead got %s" %
                         (temp_queue, f.reply_queue))
开发者ID:Acidburn0zzz,项目名称:re-core,代码行数:22,代码来源:test_fsm.py


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