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)