def dict_from_object(cls, stream_obj): """Parse and return a dictionary for a Stream Object object""" stream_dict = {} if stream_obj.get_Hash() is not None: Hashes = [] for Hash_obj in stream_obj.get_Hash(): Hashes.append(Hash.dict_from_object(Hash_obj)) stream_dict['Hashes'] = Hashes if stream_obj.get_Name() is not None: stream_dict['name'] = Base_Object_Attribute.dict_from_object(stream_obj.get_Name()) if stream_obj.get_Size_In_Bytes() is not None: stream_dict['size_in_bytes'] = Base_Object_Attribute.dict_from_object(stream_obj.get_Size_In_Bytes()) return stream_dict
def test_round_trip2(self): hash_dict = {'simple_hash_value': EMPTY_MD5, 'type': Hash.TYPE_MD5} hash_obj = Hash.object_from_dict(hash_dict) hash_dict2 = Hash.dict_from_object(hash_obj) self.assertEqual(hash_dict, hash_dict2)