def load(self, bl_collection: bpy.types.bpy_prop_collection, key: str, context: Context): # noqa N802 """ Load bl_collection elements as standalone datablocks. """ for name, item in bl_collection.items(): collection_name = BlendData.instance().bl_collection_name_from_ID( item) if skip_bpy_data_item(collection_name, item): continue uuid = ensure_uuid(item) self._data[uuid] = DatablockProxy().load( item, name, context, bpy_data_collection_name=collection_name) return self
def test_non_existing(self): # test_end_to_end.TestWorld.test_non_existing world = bpy.data.worlds[0] self.diff.diff(self.bpy_data_proxy, safe_properties) sent_ids = {} sent_ids.update({("worlds", world.name): world}) changeset = self.bpy_data_proxy.update(self.diff, {}, False, safe_properties) creations = changeset.creations # avoid clash on restore world.name = world.name + "_bak" codec = Codec() for update in creations: key = (update.collection_name, update.data("name")) sent_id = sent_ids.get(key) if sent_id is None: continue # pretend it is a new one update._datablock_uuid += "_new" # create a property on the send proxy and test that is does not fail on the receiver # property on ID update._data["does_not_exist_property"] = "" update._data["does_not_exist_struct"] = StructProxy() update._data["does_not_exist_ID"] = DatablockProxy() encoded = codec.encode(update) # sender side ####################### # receiver side decoded = codec.decode(encoded) created, _ = self.bpy_data_proxy.create_datablock(decoded) self.assertEqual(created, sent_id)