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


Python Connection._handle_amqp_frame方法代码示例

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


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

示例1: test_connection_handle_unicode_error

# 需要导入模块: from amqpstorm import Connection [as 别名]
# 或者: from amqpstorm.Connection import _handle_amqp_frame [as 别名]
    def test_connection_handle_unicode_error(self):
        """This test covers an unlikely issue triggered by network corruption.

            pamqp.decode._maybe_utf8 raises:
                UnicodeDecodeError: 'utf8' codec can't
                decode byte 0xc5 in position 1: invalid continuation byte

            The goal here is not to fix issues caused by network corruption,
            but rather to make sure that the exceptions raised when
            connections do fail are always predictable.

            Fail fast and reliably!

        :return:
        """
        connection = Connection('127.0.0.1', 'guest', 'guest', lazy=True)

        def throw_error(_):
            raise UnicodeDecodeError(str(), bytes(), 1, 1, str())

        restore_func = pamqp_frame.unmarshal
        try:
            pamqp_frame.unmarshal = throw_error

            result = connection._handle_amqp_frame('travis-ci')

            self.assertEqual(result[0], 'travis-ci')
            self.assertIsNone(result[1])
            self.assertIsNone(result[2])
        finally:
            pamqp_frame.unmarshal = restore_func

        self.assertEqual(self.get_last_log(),
                         "'' codec can't decode bytes in position 1-0: ")
开发者ID:eandersson,项目名称:amqpstorm,代码行数:36,代码来源:connection_tests.py

示例2: test_connection_handle_value_error

# 需要导入模块: from amqpstorm import Connection [as 别名]
# 或者: from amqpstorm.Connection import _handle_amqp_frame [as 别名]
    def test_connection_handle_value_error(self):
        """This test covers an unlikely issue triggered by network corruption.

            pamqp.decode._embedded_value raises:
                ValueError: Unknown type: b'\x13'

            The goal here is not to fix issues caused by network corruption,
            but rather to make sure that the exceptions raised when
            connections do fail are always predictable.

            Fail fast and reliably!

        :return:
        """
        connection = Connection('127.0.0.1', 'guest', 'guest', lazy=True)

        def throw_error(_):
            raise ValueError("Unknown type: b'\x13'")

        restore_func = pamqp_frame.unmarshal
        try:
            pamqp_frame.unmarshal = throw_error

            result = connection._handle_amqp_frame('travis-ci')

            self.assertEqual(result[0], 'travis-ci')
            self.assertIsNone(result[1])
            self.assertIsNone(result[2])
        finally:
            pamqp_frame.unmarshal = restore_func

        self.assertEqual(self.get_last_log(),
                         "Unknown type: b'\x13'")
开发者ID:eandersson,项目名称:amqpstorm,代码行数:35,代码来源:connection_tests.py

示例3: test_connection_handle_amqp_frame_none_returns_none

# 需要导入模块: from amqpstorm import Connection [as 别名]
# 或者: from amqpstorm.Connection import _handle_amqp_frame [as 别名]
    def test_connection_handle_amqp_frame_none_returns_none(self):
        connection = Connection('127.0.0.1', 'guest', 'guest', lazy=True)
        result = connection._handle_amqp_frame('')

        self.assertEqual(result[0], '')
        self.assertIsNone(result[1])
        self.assertIsNone(result[2])
开发者ID:eandersson,项目名称:amqpstorm,代码行数:9,代码来源:connection_tests.py

示例4: test_connection_basic_handle_amqp_frame

# 需要导入模块: from amqpstorm import Connection [as 别名]
# 或者: from amqpstorm.Connection import _handle_amqp_frame [as 别名]
    def test_connection_basic_handle_amqp_frame(self):
        connection = Connection('127.0.0.1', 'guest', 'guest', lazy=True)
        payload = (
            b'\x01\x00\x00\x00\x00\x00\x0c\x00\n\x00\x1e\x00\x00\x00'
            b'\x02\x00\x00\x00<\xce'
        )

        data_in, channel_id, frame_in = connection._handle_amqp_frame(payload)

        self.assertEqual(data_in, b'')
        self.assertEqual(channel_id, 0)
        self.assertIsInstance(frame_in, specification.Connection.Tune)
开发者ID:eandersson,项目名称:amqpstorm,代码行数:14,代码来源:connection_tests.py

示例5: test_connection_handle_amqp_frame_error

# 需要导入模块: from amqpstorm import Connection [as 别名]
# 或者: from amqpstorm.Connection import _handle_amqp_frame [as 别名]
    def test_connection_handle_amqp_frame_error(self):
        connection = Connection('127.0.0.1', 'guest', 'guest', lazy=True)

        def throw_error(*_):
            raise pamqp_spec.AMQPFrameError()

        restore_func = pamqp_frame.unmarshal
        try:
            pamqp_frame.unmarshal = throw_error

            result = connection._handle_amqp_frame('error')

            self.assertEqual(result[0], 'error')
            self.assertIsNone(result[1])
            self.assertIsNone(result[2])
        finally:
            pamqp_frame.unmarshal = restore_func
开发者ID:exg77,项目名称:amqpstorm,代码行数:19,代码来源:connection_tests.py

示例6: test_connection_handle_amqp_frame_error

# 需要导入模块: from amqpstorm import Connection [as 别名]
# 或者: from amqpstorm.Connection import _handle_amqp_frame [as 别名]
    def test_connection_handle_amqp_frame_error(self):
        connection = Connection('127.0.0.1', 'guest', 'guest', lazy=True)

        def throw_error(*_):
            raise specification.AMQPFrameError()

        restore_func = pamqp_frame.unmarshal
        try:
            pamqp_frame.unmarshal = throw_error

            result = connection._handle_amqp_frame('travis-ci')

            self.assertEqual(result[0], 'travis-ci')
            self.assertIsNone(result[1])
            self.assertIsNone(result[2])
        finally:
            pamqp_frame.unmarshal = restore_func

        self.assertEqual(self.get_last_log(),
                         'AMQPFrameError: AMQPFrameError()')
开发者ID:eandersson,项目名称:amqpstorm,代码行数:22,代码来源:connection_tests.py

示例7: test_connection_basic_handle_amqp_frame

# 需要导入模块: from amqpstorm import Connection [as 别名]
# 或者: from amqpstorm.Connection import _handle_amqp_frame [as 别名]
    def test_connection_basic_handle_amqp_frame(self):
        connection = Connection('127.0.0.1', 'guest', 'guest', lazy=True)
        cancel_ok_frame = spec_basic.CancelOk().marshal()

        self.assertEqual(connection._handle_amqp_frame(cancel_ok_frame),
                         (b'\x00', None, None))
开发者ID:exg77,项目名称:amqpstorm,代码行数:8,代码来源:connection_tests.py


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