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


Python amqpstorm.Channel类代码示例

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


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

示例1: test_basic_get_invalid_parameter

    def test_basic_get_invalid_parameter(self):
        channel = Channel(0, FakeConnection(), 360)
        channel.set_state(Channel.OPEN)
        basic = Basic(channel)

        self.assertRaisesRegexp(
            exception.AMQPInvalidArgument,
            'queue should be a string',
            basic.get, None
        )

        self.assertRaisesRegexp(
            exception.AMQPInvalidArgument,
            'no_ack should be a boolean',
            basic.get, '', 'travis-ci'
        )

        channel.consumer_tags.append('travis-ci')

        self.assertRaisesRegexp(
            exception.AMQPChannelError,
            "Cannot call 'get' when channel "
            "is set to consume",
            basic.get, '', True, 'travis-ci'
        )
开发者ID:eandersson,项目名称:amqpstorm,代码行数:25,代码来源:basic_exception_tests.py

示例2: test_channel_start_consuming_no_consumer_tags

    def test_channel_start_consuming_no_consumer_tags(self):
        channel = Channel(0, FakeConnection(), 360)
        channel.set_state(channel.OPEN)

        channel._consumer_callbacks = ['fake']

        self.assertIsNone(channel.start_consuming())
开发者ID:eandersson,项目名称:amqpstorm,代码行数:7,代码来源:channel_message_handling_tests.py

示例3: test_exchange_unbind_invalid_parameter

    def test_exchange_unbind_invalid_parameter(self):
        channel = Channel(0, FakeConnection(), 360)
        channel.set_state(Channel.OPEN)
        exchange = Exchange(channel)

        self.assertRaisesRegexp(
            exception.AMQPInvalidArgument,
            'destination should be a string',
            exchange.unbind, None
        )

        self.assertRaisesRegexp(
            exception.AMQPInvalidArgument,
            'source should be a string',
            exchange.unbind, '', None
        )

        self.assertRaisesRegexp(
            exception.AMQPInvalidArgument,
            'routing_key should be a string',
            exchange.unbind, '', '', None
        )

        self.assertRaisesRegexp(
            exception.AMQPInvalidArgument,
            'arguments should be a dict or None',
            exchange.unbind, '', '', '', []
        )
开发者ID:eandersson,项目名称:amqpstorm,代码行数:28,代码来源:exchange_exception_tests.py

示例4: test_channel_consume_ok_frame

    def test_channel_consume_ok_frame(self):
        tag = 'hello-world'
        channel = Channel(0, None, rpc_timeout=360)

        channel.on_frame(specification.Basic.ConsumeOk(tag))

        self.assertEqual(channel.consumer_tags[0], tag)
开发者ID:exg77,项目名称:amqpstorm,代码行数:7,代码来源:channel_tests.py

示例5: test_build_empty_inbound_messages

 def test_build_empty_inbound_messages(self):
     channel = Channel(0, FakeConnection(), 360)
     channel.set_state(Channel.OPEN)
     result = None
     for message in channel.build_inbound_messages(break_on_empty=True):
         result = message
     self.assertIsNone(result)
开发者ID:gaochunzy,项目名称:amqp-storm,代码行数:7,代码来源:channel_tests.py

示例6: test_channel_cancel_ok_frame

    def test_channel_cancel_ok_frame(self):
        tag = 'hello-world'
        channel = Channel(0, None, rpc_timeout=360)
        channel.add_consumer_tag(tag)

        channel.on_frame(specification.Basic.CancelOk(tag))

        self.assertFalse(channel.consumer_tags)
开发者ID:exg77,项目名称:amqpstorm,代码行数:8,代码来源:channel_tests.py

示例7: test_channel_closed_after_connection_closed

    def test_channel_closed_after_connection_closed(self):
        channel = Channel(0, FakeConnection(FakeConnection.CLOSED), 360)
        channel.set_state(channel.OPEN)

        self.assertTrue(channel.is_open)
        self.assertRaisesRegexp(exception.AMQPConnectionError,
                                'connection was closed',
                                channel.check_for_errors)
        self.assertTrue(channel.is_closed)
开发者ID:exg77,项目名称:amqpstorm,代码行数:9,代码来源:channel_tests.py

示例8: test_channel_build_empty_inbound_messages

    def test_channel_build_empty_inbound_messages(self):
        channel = Channel(0, FakeConnection(), 360)
        channel.set_state(Channel.OPEN)
        generator = channel.build_inbound_messages(break_on_empty=True)

        if hasattr(generator, 'next'):
            self.assertRaises(StopIteration, generator.next)
        else:
            self.assertRaises(StopIteration, generator.__next__)
开发者ID:eandersson,项目名称:amqpstorm,代码行数:9,代码来源:channel_message_handling_tests.py

示例9: test_channel_basic_cancel_frame

    def test_channel_basic_cancel_frame(self):
        connection = amqpstorm.Connection('localhost', 'guest', 'guest',
                                          lazy=True)
        channel = Channel(0, connection, rpc_timeout=360)

        channel.on_frame(specification.Basic.Cancel('unit-test'))

        self.assertEqual(self.logging_handler.messages['warning'][0],
                         'Received Basic.Cancel on consumer_tag: unit-test')
开发者ID:exg77,项目名称:amqpstorm,代码行数:9,代码来源:channel_tests.py

示例10: test_channel_build_inbound_raises

    def test_channel_build_inbound_raises(self, _):
        channel = Channel(0, FakeConnection(), 360)
        channel.set_state(Channel.OPEN)

        generator = channel.build_inbound_messages(break_on_empty=False)
        if hasattr(generator, 'next'):
            self.assertRaises(AMQPChannelError, generator.next)
        else:
            self.assertRaises(AMQPChannelError, generator.__next__)
开发者ID:eandersson,项目名称:amqpstorm,代码行数:9,代码来源:channel_exception_tests.py

示例11: test_channel_raises_when_closed

    def test_channel_raises_when_closed(self):
        channel = Channel(0, FakeConnection(FakeConnection.OPEN), 360)
        channel.set_state(channel.CLOSED)

        self.assertFalse(channel.is_open)
        self.assertRaisesRegexp(exception.AMQPChannelError,
                                'channel was closed',
                                channel.check_for_errors)
        self.assertTrue(channel.is_closed)
开发者ID:exg77,项目名称:amqpstorm,代码行数:9,代码来源:channel_tests.py

示例12: test_basic_recover_invalid_parameter

    def test_basic_recover_invalid_parameter(self):
        channel = Channel(0, FakeConnection(), 360)
        channel.set_state(Channel.OPEN)
        basic = Basic(channel)

        self.assertRaisesRegexp(
            exception.AMQPInvalidArgument,
            'requeue should be a boolean',
            basic.recover, None
        )
开发者ID:eandersson,项目名称:amqpstorm,代码行数:10,代码来源:basic_exception_tests.py

示例13: test_basic_cancel_invalid_parameter

    def test_basic_cancel_invalid_parameter(self):
        channel = Channel(0, FakeConnection(), 360)
        channel.set_state(Channel.OPEN)
        basic = Basic(channel)

        self.assertRaisesRegexp(
            exception.AMQPInvalidArgument,
            'consumer_tag should be a string',
            basic.cancel, None
        )
开发者ID:eandersson,项目名称:amqpstorm,代码行数:10,代码来源:basic_exception_tests.py

示例14: test_channel_unhandled_frame

    def test_channel_unhandled_frame(self):
        connection = amqpstorm.Connection('localhost', 'guest', 'guest',
                                          lazy=True)
        channel = Channel(0, connection, rpc_timeout=360)

        channel.on_frame(FakeFrame())

        self.assertEqual(self.logging_handler.messages['error'][0],
                         "[Channel0] Unhandled Frame: FakeFrame -- "
                         "{'data_1': 'hello world'}")
开发者ID:exg77,项目名称:amqpstorm,代码行数:10,代码来源:channel_tests.py

示例15: test_channel_close_frame

    def test_channel_close_frame(self):
        connection = amqpstorm.Connection('localhost', 'guest', 'guest',
                                          lazy=True)
        channel = Channel(0, connection, rpc_timeout=360)

        channel.on_frame(specification.Channel.Close(reply_code=500,
                                                     reply_text='test'))

        self.assertEqual(str(channel.exceptions[0]),
                         'Channel 0 was closed by remote server: test')
开发者ID:exg77,项目名称:amqpstorm,代码行数:10,代码来源:channel_tests.py


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