def test_list(self): self.mark_initial_frame_as_non_final() l = ["a", "b", "c", "😃"] ListMultiFrameCodec.encode(self.buf, l, StringCodec.encode) ListMultiFrameCodec.encode_nullable(self.buf, l, StringCodec.encode) ListMultiFrameCodec.encode_nullable(self.buf, None, StringCodec.encode) ListMultiFrameCodec.encode_contains_nullable(self.buf, l, StringCodec.encode) ListMultiFrameCodec.encode_contains_nullable(self.buf, [None], StringCodec.encode, True) message = self.write_and_decode() message.next_frame() # initial frame self.assertEqual( l, ListMultiFrameCodec.decode(message, StringCodec.decode)) self.assertEqual( l, ListMultiFrameCodec.decode_nullable(message, StringCodec.decode)) self.assertIsNone( ListMultiFrameCodec.decode_nullable(message, StringCodec.decode)) self.assertEqual( l, ListMultiFrameCodec.decode_contains_nullable( message, StringCodec.decode)) self.assertEqual([None], ListMultiFrameCodec.decode_contains_nullable( message, StringCodec.decode))
def decode_response(msg): msg.next_frame() return ListMultiFrameCodec.decode_contains_nullable(msg, DataCodec.decode)