Esempio n. 1
0
    def testJsonRoundTripUnknownArtifactClass(self):
        channel = Channel(type=_MyType)

        serialized = channel.to_json_dict()
        serialized['type']['name'] = 'UnknownTypeName'

        rehydrated = Channel.from_json_dict(serialized)
        self.assertEqual('UnknownTypeName', rehydrated.type_name)
        self.assertEqual(channel.type._get_artifact_type().properties,
                         rehydrated.type._get_artifact_type().properties)
        self.assertTrue(rehydrated.type._AUTOGENERATED)
Esempio n. 2
0
 def testJsonRoundTrip(self):
     channel = Channel(
         type=_MyType,
         additional_properties={
             'string_value':
             metadata_store_pb2.Value(string_value='forty-two')
         },
         additional_custom_properties={
             'int_value': metadata_store_pb2.Value(int_value=42)
         })
     serialized = channel.to_json_dict()
     rehydrated = Channel.from_json_dict(serialized)
     self.assertIs(channel.type, rehydrated.type)
     self.assertEqual(channel.type_name, rehydrated.type_name)
     self.assertEqual(channel.additional_properties,
                      rehydrated.additional_properties)
     self.assertEqual(channel.additional_custom_properties,
                      rehydrated.additional_custom_properties)
Esempio n. 3
0
 def testJsonRoundTrip(self):
     channel = Channel(type=_MyType, artifacts=[_MyType()])
     serialized = channel.to_json_dict()
     rehydrated = Channel.from_json_dict(serialized)
     self.assertIs(channel.type, rehydrated.type)
     self.assertEqual(channel.type_name, rehydrated.type_name)