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


Python Producer.prepare方法代码示例

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


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

示例1: test_prepare_custom_content_type

# 需要导入模块: from kombu.messaging import Producer [as 别名]
# 或者: from kombu.messaging.Producer import prepare [as 别名]
 def test_prepare_custom_content_type(self):
     message = "the quick brown fox"
     channel = self.connection.channel()
     p = Producer(channel, self.exchange, serializer="json")
     m, ctype, cencoding = p.prepare(message, content_type="custom")
     self.assertEqual(m, message)
     self.assertEqual(ctype, "custom")
     self.assertEqual(cencoding, "binary")
     m, ctype, cencoding = p.prepare(message, content_type="custom",
                                     content_encoding="alien")
     self.assertEqual(m, message)
     self.assertEqual(ctype, "custom")
     self.assertEqual(cencoding, "alien")
开发者ID:bradjasper,项目名称:kombu,代码行数:15,代码来源:test_messaging.py

示例2: test_prepare_is_already_unicode

# 需要导入模块: from kombu.messaging import Producer [as 别名]
# 或者: from kombu.messaging.Producer import prepare [as 别名]
 def test_prepare_is_already_unicode(self):
     message = u"the quick brown fox"
     channel = self.connection.channel()
     p = Producer(channel, self.exchange, serializer="json")
     m, ctype, cencoding = p.prepare(message, content_type="text/plain")
     self.assertEqual(m, message)
     self.assertEqual(ctype, "text/plain")
     self.assertEqual(cencoding, "utf-8")
     m, ctype, cencoding = p.prepare(message, content_type="text/plain",
                                     content_encoding="utf-8")
     self.assertEqual(m, message)
     self.assertEqual(ctype, "text/plain")
     self.assertEqual(cencoding, "utf-8")
开发者ID:bradjasper,项目名称:kombu,代码行数:15,代码来源:test_messaging.py

示例3: test_prepare

# 需要导入模块: from kombu.messaging import Producer [as 别名]
# 或者: from kombu.messaging.Producer import prepare [as 别名]
 def test_prepare(self):
     message = {u"the quick brown fox": u"jumps over the lazy dog"}
     channel = self.connection.channel()
     p = Producer(channel, self.exchange, serializer="json")
     m, ctype, cencoding = p.prepare(message)
     self.assertDictEqual(message, simplejson.loads(m))
     self.assertEqual(ctype, "application/json")
     self.assertEqual(cencoding, "utf-8")
开发者ID:bradjasper,项目名称:kombu,代码行数:10,代码来源:test_messaging.py


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