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


Python amqpstorm.Message类代码示例

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


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

示例1: test_message_auto_decode_cache

    def test_message_auto_decode_cache(self):
        message = Message(body=self.message,
                          channel=None)

        self.assertEqual(self.message, message.body)
        message._body = 'invalidate'
        self.assertEqual(self.message, message.body)
开发者ID:eandersson,项目名称:amqpstorm,代码行数:7,代码来源:message_tests.py

示例2: test_message_json

    def test_message_json(self):
        body = '{"key": "value"}'
        message = Message(body=body, channel=None)

        result = message.json()

        self.assertIsInstance(result, dict)
        self.assertEqual(result['key'], 'value')
开发者ID:eandersson,项目名称:amqpstorm,代码行数:8,代码来源:message_tests.py

示例3: test_message_auto_decode_cache

    def test_message_auto_decode_cache(self):
        body = 'Hello World',
        message = Message(body=body,
                          channel=None)

        self.assertEqual(body, message.body)
        message._body = 'invalidate'
        self.assertEqual(body, message.body)
开发者ID:exg77,项目名称:amqpstorm,代码行数:8,代码来源:message_tests.py

示例4: test_to_dict

 def test_to_dict(self):
     body = b'Hello World'
     message = Message(body=body,
                       properties={'key': 'value'},
                       method={'key': 'value'},
                       channel=None)
     result = message.to_dict()
     self.assertIsInstance(result, dict)
     self.assertEqual(result['body'], body)
开发者ID:gaochunzy,项目名称:amqp-storm,代码行数:9,代码来源:message_tests.py

示例5: test_to_tuple

 def test_to_tuple(self):
     body = b'Hello World'
     message = Message(body=body,
                       properties={'key': 'value'},
                       method={'key': 'value'},
                       channel=None)
     body, channel, method, properties = message.to_tuple()
     self.assertEqual(body, body)
     self.assertIsInstance(method, dict)
     self.assertIsInstance(properties, dict)
     self.assertIsNone(channel)
开发者ID:gaochunzy,项目名称:amqp-storm,代码行数:11,代码来源:message_tests.py

示例6: test_message_to_dict

    def test_message_to_dict(self):
        body = self.message
        properties = {'key': 'value'}
        method = {b'alternative': 'value'}
        message = Message(body=body,
                          properties=properties,
                          method=method,
                          channel=None)

        result = message.to_dict()

        self.assertIsInstance(result, dict)
        self.assertEqual(result['body'], body)
        self.assertEqual(result['properties'], properties)
        self.assertEqual(result['method'], method)
开发者ID:eandersson,项目名称:amqpstorm,代码行数:15,代码来源:message_tests.py

示例7: test_message_delivery_mode_two

    def test_message_delivery_mode_two(self):
        delivery_mode = 2

        message = Message.create(None, '')
        message.delivery_mode = delivery_mode

        self.assertEqual(delivery_mode, message.delivery_mode)
开发者ID:eandersson,项目名称:amqpstorm,代码行数:7,代码来源:message_tests.py

示例8: publish_message

def publish_message(channel, body, queue, expiration="600"):
    # Create the message with a expiration (time to live).
    message = Message.create(channel, body,
                             properties={"expiration": expiration})

    # Publish the message to a queue.
    message.publish(queue)
开发者ID:eandersson,项目名称:amqpstorm,代码行数:7,代码来源:publish_message_with_expiration.py

示例9: test_message_content_type_custom_value

    def test_message_content_type_custom_value(self):
        content_type = 'application/json'

        message = Message.create(None, '')
        message.content_type = content_type

        self.assertEqual(content_type, message.content_type)
开发者ID:eandersson,项目名称:amqpstorm,代码行数:7,代码来源:message_tests.py

示例10: test_functional_publish_and_change_app_id

    def test_functional_publish_and_change_app_id(self):
        self.channel.confirm_deliveries()
        self.channel.queue.declare(self.queue_name)
        message = Message.create(self.channel,
                                 body=self.message)
        message.app_id = 'travis-ci'
        message.publish(self.queue_name)

        message = self.channel.basic.get(self.queue_name, no_ack=True)

        # Check original app_id
        self.assertEqual(message.app_id, 'travis-ci')

        # Assign Property app_id
        app_id = 'travis-ci-2'.encode('utf-8')
        message.app_id = app_id

        # Check that it was set correctly.
        self.assertEqual(message.properties['app_id'], app_id)

        # Get Property Correlation Id
        correlation_id = message.correlation_id

        # Publish Message
        message.publish(routing_key=self.queue_name)

        # Sleep for 0.01s to make sure RabbitMQ has time to catch up.
        time.sleep(0.01)

        payload = self.channel.basic.get(self.queue_name, no_ack=True)
        self.assertEqual(payload.app_id, app_id.decode('utf-8'))
        self.assertEqual(payload.correlation_id, correlation_id)
        self.assertIsInstance(payload.properties['app_id'], str)
        self.assertIsInstance(payload.properties['correlation_id'], str)
开发者ID:eandersson,项目名称:amqpstorm,代码行数:34,代码来源:generic_tests.py

示例11: test_message_reply_to_custom_value

    def test_message_reply_to_custom_value(self):
        reply_to = str(uuid.uuid4())

        message = Message.create(None, '')
        message.reply_to = reply_to

        self.assertEqual(reply_to, message.reply_to)
开发者ID:eandersson,项目名称:amqpstorm,代码行数:7,代码来源:message_tests.py

示例12: test_message_timestamp_custom_value

    def test_message_timestamp_custom_value(self):
        dt = datetime.now()

        message = Message.create(None, '')
        message.timestamp = dt

        self.assertEqual(dt, message.timestamp)
开发者ID:eandersson,项目名称:amqpstorm,代码行数:7,代码来源:message_tests.py

示例13: test_message_correlation_id_custom_value

    def test_message_correlation_id_custom_value(self):
        correlation_id = str(uuid.uuid4())

        message = Message.create(None, '')
        message.correlation_id = correlation_id

        self.assertEqual(correlation_id, message.correlation_id)
开发者ID:eandersson,项目名称:amqpstorm,代码行数:7,代码来源:message_tests.py

示例14: test_message_priority_three

    def test_message_priority_three(self):
        priority = 3

        message = Message.create(None, '')
        message.priority = priority

        self.assertEqual(priority, message.priority)
开发者ID:eandersson,项目名称:amqpstorm,代码行数:7,代码来源:message_tests.py

示例15: test_message_app_id_custom_value

    def test_message_app_id_custom_value(self):
        app_id = 'my-app'

        message = Message.create(None, '')
        message.app_id = app_id

        self.assertEqual(app_id, message.app_id)
开发者ID:eandersson,项目名称:amqpstorm,代码行数:7,代码来源:message_tests.py


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