當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。