From 06a74e78169ff60082716c0bd85c0b76de6bb885 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 11 Nov 2021 14:54:26 +0100 Subject: LibLink/Append tests: Add basic testing of `bpy.data.libraries.load` code. --- tests/python/bl_blendfile_liblink.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'tests') diff --git a/tests/python/bl_blendfile_liblink.py b/tests/python/bl_blendfile_liblink.py index 760a1a15959..f7bd2308061 100644 --- a/tests/python/bl_blendfile_liblink.py +++ b/tests/python/bl_blendfile_liblink.py @@ -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, ) -- cgit v1.2.3