def test_global_encode_decode(self):
        config = SerializationConfig()
        config.global_serializer = TestGlobalSerializer

        service = SerializationServiceV1(serialization_config=config)
        obj = CustomClass("uid", "some name", "description text")
        data = service.to_data(obj)

        obj2 = service.to_object(data)
        self.assertEqual(obj, obj2)
        self.assertEqual("GLOBAL", obj2.source)
示例#2
0
    def test_global_encode_decode(self):
        config = SerializationConfig()
        config.global_serializer = TestGlobalSerializer

        service = SerializationServiceV1(serialization_config=config)
        obj = CustomClass("uid", "some name", "description text")
        data = service.to_data(obj)

        obj2 = service.to_object(data)
        self.assertEqual(obj, obj2)
        self.assertEqual("GLOBAL", obj2.source)
    def test_global_custom_serializer(self):
        config = SerializationConfig()
        config.set_custom_serializer(CustomClass, CustomSerializer)
        config.global_serializer = TestGlobalSerializer

        service = SerializationServiceV1(serialization_config=config)
        obj = CustomClass("uid", "some name", "description text")
        data = service.to_data(obj)

        obj2 = service.to_object(data)
        self.assertEqual(obj, obj2)
        self.assertEqual("CUSTOM", obj2.source)
示例#4
0
    def test_global_custom_serializer(self):
        config = SerializationConfig()
        config.set_custom_serializer(CustomClass, CustomSerializer)
        config.global_serializer = TestGlobalSerializer

        service = SerializationServiceV1(serialization_config=config)
        obj = CustomClass("uid", "some name", "description text")
        data = service.to_data(obj)

        obj2 = service.to_object(data)
        self.assertEqual(obj, obj2)
        self.assertEqual("CUSTOM", obj2.source)