Пример #1
0
    def testCustomClassSerialization(self):
        my_custom = MyCustomClass(1234, "my_name")
        serialized = serialization.serialize(my_custom)

        self.assertTrue(
            serialized.representation.Is(
                serialization_test_pb2.MyCustomRepresentation.DESCRIPTOR))

        proto = serialization_test_pb2.MyCustomRepresentation()
        serialized.representation.Unpack(proto)
        self.assertEqual(proto.index, my_custom.index)
        self.assertEqual(proto.name, my_custom.name)
Пример #2
0
 def experimental_as_proto(self):
     return serialization_test_pb2.MyCustomRepresentation()
Пример #3
0
 def experimental_as_proto(self):
     proto = serialization_test_pb2.MyCustomRepresentation(index=self.index,
                                                           name=self.name)
     return proto
Пример #4
0
 def to_proto(self):
     return serialization_test_pb2.MyCustomRepresentation()