LibLink/Append tests: Add basic testing of `bpy.data.libraries.load` code.

This commit is contained in:
Bastien Montagne 2021-11-11 14:54:26 +01:00
parent 9f31b9b7d3
commit 06a74e7816
1 changed files with 33 additions and 0 deletions

View File

@ -435,12 +435,45 @@ class TestBlendLibLibraryRelocate(TestBlendLibLinkHelper):
assert(orig_data == relocate_data)
class TestBlendLibDataLibrariesLoad(TestBlendLibLinkHelper):
def __init__(self, args):
self.args = args
def test_link_relocate(self):
output_dir = self.args.output_dir
output_lib_path = self.init_lib_data_basic()
# Simple link of a single Object, and reload.
self.reset_blender()
with bpy.data.libraries.load(filepath=output_lib_path) as lib_ctx:
lib_src, lib_link = lib_ctx
assert(len(lib_src.meshes) == 1)
assert(len(lib_src.objects) == 1)
assert(len(lib_src.collections) == 1)
assert(len(lib_link.meshes) == 0)
assert(len(lib_link.objects) == 0)
assert(len(lib_link.collections) == 0)
lib_link.collections.append(lib_src.collections[0])
# Linking happens when living the context manager.
assert(len(bpy.data.meshes) == 1)
assert(len(bpy.data.objects) == 1) # This code does no instantiation.
assert(len(bpy.data.collections) == 1)
TESTS = (
TestBlendLibLinkSaveLoadBasic,
TestBlendLibAppendBasic,
TestBlendLibAppendReuseID,
TestBlendLibLibraryReload,
TestBlendLibLibraryRelocate,
TestBlendLibDataLibrariesLoad,
)