本文整理汇总了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")
示例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")
示例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")