def decode(msg): msg.next_frame() anchor_page_list = ListIntegerCodec.decode(msg) anchor_data_list = EntryListCodec.decode(msg, DataCodec.decode, DataCodec.decode) CodecUtil.fast_forward_to_end_frame(msg) return AnchorDataListHolder(anchor_page_list, anchor_data_list)
def decode_response(msg): msg.next_frame() response = dict() response["response"] = EntryListCodec.decode(msg, DataCodec.decode, DataCodec.decode) response["anchor_data_list"] = AnchorDataListHolderCodec.decode(msg) return response
def test_entry_list(self): self.mark_initial_frame_as_non_final() entries = [("a", "1"), ("b", "2"), ("c", "3")] EntryListCodec.encode(self.buf, entries, StringCodec.encode, StringCodec.encode) EntryListCodec.encode_nullable(self.buf, entries, StringCodec.encode, StringCodec.encode) EntryListCodec.encode_nullable(self.buf, None, StringCodec.encode, StringCodec.encode, True) message = self.write_and_decode() message.next_frame() # initial frame self.assertEqual(entries, EntryListCodec.decode(message, StringCodec.decode, StringCodec.decode)) self.assertEqual(entries, EntryListCodec.decode_nullable(message, StringCodec.decode, StringCodec.decode)) self.assertIsNone(EntryListCodec.decode_nullable(message, StringCodec.decode, StringCodec.decode))
def decode_response(msg): msg.next_frame() return EntryListCodec.decode(msg, DataCodec.decode, DataCodec.decode)