def test_encode(self): buf = amf3.encode(1) self.assertTrue(isinstance(buf, util.BufferedByteStream)) self.assertEquals(amf3.encode(1).getvalue(), '\x04\x01') self.assertEquals(amf3.encode('foo', 'bar').getvalue(), '\x06\x07foo\x06\x07bar')
def test_encode_amf3(self): x = io.ArrayList() x.append('eggs') stream = amf3.encode(x) self.assertEquals(stream.getvalue(), '\n\x077flex.messaging.io.ArrayList\t\x03\x01\x06\teggs')
def test_encode_with_context(self): context = amf3.Context() obj = object() context.addObject(obj) self.assertEquals(amf3.encode(obj, context=context).getvalue(), '\n\x00')