Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2021-11-02 17:33:30 +0300
committerBastien Montagne <bastien@blender.org>2021-11-02 17:33:30 +0300
commit1b2342b4d3641a5b438cba86a9378be944cec103 (patch)
treeb73a18718e1ee437d729f87546a999d79af3f753 /tests
parenta7e92843f72efe0f395eb67d24a419f83f60dc70 (diff)
Tests: Add basic unittest for library reload and relocate operators.
Diffstat (limited to 'tests')
-rw-r--r--tests/python/bl_blendfile_liblink.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/python/bl_blendfile_liblink.py b/tests/python/bl_blendfile_liblink.py
index ab26059e944..6017d3f1a1e 100644
--- a/tests/python/bl_blendfile_liblink.py
+++ b/tests/python/bl_blendfile_liblink.py
@@ -370,10 +370,69 @@ class TestBlendLibAppendReuseID(TestBlendLibLinkHelper):
assert(len(bpy.data.collections) == 0) # Scene's master collection is not listed here
+class TestBlendLibLibraryReloadRelocate(TestBlendLibLinkHelper):
+
+ def __init__(self, args):
+ self.args = args
+
+ def test_link_reload(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()
+
+ link_dir = os.path.join(output_lib_path, "Object")
+ bpy.ops.wm.link(directory=link_dir, filename="LibMesh")
+
+ assert(len(bpy.data.meshes) == 1)
+ assert(len(bpy.data.objects) == 1)
+ assert(len(bpy.data.collections) == 0) # Scene's master collection is not listed here
+
+ orig_data = self.blender_data_to_tuple(bpy.data, "orig_data")
+
+ bpy.ops.wm.lib_reload(library=bpy.data.objects[0].name)
+
+ reload_data = self.blender_data_to_tuple(bpy.data, "reload_data")
+
+ print(orig_data)
+ print(reload_data)
+ assert(orig_data == reload_data)
+
+ 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()
+
+ link_dir = os.path.join(output_lib_path, "Object")
+ bpy.ops.wm.link(directory=link_dir, filename="LibMesh")
+
+ assert(len(bpy.data.meshes) == 1)
+ assert(len(bpy.data.objects) == 1)
+ assert(len(bpy.data.collections) == 0) # Scene's master collection is not listed here
+
+ orig_data = self.blender_data_to_tuple(bpy.data, "orig_data")
+
+ lib_path, lib_ext = os.path.splitext(output_lib_path)
+ new_lib_path = lib_path + "_relocate" + lib_ext
+ os.rename(output_lib_path, new_lib_path)
+
+ bpy.ops.wm.lib_relocate(library=bpy.data.objects[0].name, directory="", filename=new_lib_path)
+
+ relocate_data = self.blender_data_to_tuple(bpy.data, "relocate_data")
+
+ print(orig_data)
+ print(relocate_data)
+ assert(orig_data == relocate_data)
+
+
TESTS = (
TestBlendLibLinkSaveLoadBasic,
TestBlendLibAppendBasic,
TestBlendLibAppendReuseID,
+ TestBlendLibLibraryReloadRelocate,
)