Ejemplo n.º 1
0
 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")
Ejemplo n.º 2
0
 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")
Ejemplo n.º 3
0
 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")