Layers unittesting: update after doversion changes
authorDalai Felinto <dfelinto@gmail.com>
Mon, 20 Mar 2017 09:30:19 +0000 (10:30 +0100)
committerDalai Felinto <dfelinto@gmail.com>
Mon, 20 Mar 2017 09:30:19 +0000 (10:30 +0100)
Collections now are called "Collection 1", instead of "1"

tests/python/render_layer/render_layer_common.py
tests/python/render_layer/test_active_collection.py
tests/python/render_layer/test_layer_linking.py
tests/python/render_layer/test_object_copy.py
tests/python/render_layer/test_object_delete.py
tests/python/render_layer/test_operator_context.py
tests/python/render_layer/test_scene_copy.py
tests/python/render_layer/test_scene_write_read.py
tests/python/render_layer/test_syncing.py

index ddfbc629605873f6eef5f29aae58d4d0db1e3699..f12994bb5157004074e8a736ffffc33144b94187 100644 (file)
@@ -258,6 +258,7 @@ class RenderLayerTesting(unittest.TestCase):
 
             # open file
             bpy.ops.wm.open_mainfile('EXEC_DEFAULT', filepath=filepath_layers)
+            self.rename_collections()
 
             # create sub-collections
             three_b = bpy.data.objects.get('T.3b')
@@ -360,6 +361,25 @@ class RenderLayerTesting(unittest.TestCase):
         while master_collection.collections:
             master_collection.collections.remove(master_collection.collections[0])
 
+    def rename_collections(self, collection=None):
+        """
+        Rename 'Collection 1' to '1'
+        """
+        def strip_name(collection):
+            import re
+            if collection.name.startswith("Default Collection"):
+                collection.name = '1'
+            else:
+                collection.name = re.findall(r'\d+', collection.name)[0]
+
+        if collection is None:
+            import bpy
+            collection = bpy.context.scene.master_collection
+
+        for nested_collection in collection.collections:
+            strip_name(nested_collection)
+            self.rename_collections(nested_collection)
+
 
 class MoveSceneCollectionTesting(RenderLayerTesting):
     """
index 5cd66538ff5d10558afd3f1899c73ec777cb614a..e3eaafa4baeefb033efbfb75258153169732d633 100644 (file)
@@ -30,6 +30,7 @@ class UnitTesting(RenderLayerTesting):
 
         # open file
         bpy.ops.wm.open_mainfile('EXEC_DEFAULT', filepath=filepath_layers)
+        self.rename_collections()
 
         # create sub-collections
         three_b = bpy.data.objects.get('T.3b')
index 35af3d6a968263f3a443a83e8020069b8db74da2..ff6ae8766ca1197da4bff34dad1caed3f4b6f283 100644 (file)
@@ -29,6 +29,7 @@ class UnitTesting(RenderLayerTesting):
 
             # open file
             bpy.ops.wm.open_mainfile('EXEC_DEFAULT', filepath=filepath_layers)
+            self.rename_collections()
 
             # create sub-collections
             three_b = bpy.data.objects.get('T.3b')
index 419f8f418a589cbdb6d7a3e3c84057250ad11ab0..5b16875f6a2cfa06e01c6a0b3e59858151b9a103 100644 (file)
@@ -30,6 +30,7 @@ class UnitTesting(RenderLayerTesting):
 
             # open file
             bpy.ops.wm.open_mainfile('EXEC_DEFAULT', filepath=filepath_layers)
+            self.rename_collections()
 
             # create sub-collections
             three_b = bpy.data.objects.get('T.3b')
index 693357d7de007b9881aa26f8e240435df8d701cb..d5752b1eaf568f3aff1feacdd04a94c2aceace23 100644 (file)
@@ -30,6 +30,7 @@ class UnitTesting(RenderLayerTesting):
 
             # open file
             bpy.ops.wm.open_mainfile('EXEC_DEFAULT', filepath=filepath_layers)
+            self.rename_collections()
 
             # create sub-collections
             three_b = bpy.data.objects.get('T.3b')
index 3c51327fbe8c839e95c115506c08ef0d00956ece..fd90732b0ce4a1b414ebc74b090666920d79e4f4 100644 (file)
@@ -75,6 +75,7 @@ class UnitTesting(RenderLayerTesting):
         ROOT = self.get_root()
         filepath_layers = os.path.join(ROOT, 'layers.blend')
         bpy.ops.wm.open_mainfile('EXEC_DEFAULT', filepath=filepath_layers)
+        self.rename_collections()
 
         # change the file
         three_b = bpy.data.objects.get('T.3b')
index bfa473a11d6632ace125f2e3882b846c7132c44f..af8138db8a318c5f12a79e667f7cf3114e77a994 100644 (file)
@@ -36,6 +36,7 @@ class UnitTesting(RenderLayerTesting):
             filepath_json = os.path.join(dirpath, "{0}.json".format(copy_mode))
 
             bpy.ops.wm.open_mainfile('EXEC_DEFAULT', filepath=filepath_layers)
+            self.rename_collections()
             bpy.ops.scene.new(type=copy_mode)
             bpy.ops.wm.save_mainfile('EXEC_DEFAULT', filepath=filepath_saved)
 
index 020c81f7d37ed7b8aff54cabfbb7263d2b352331..6d7d3766ff44e0ca3790054412a329fa7c326955 100644 (file)
@@ -35,6 +35,7 @@ class UnitTesting(RenderLayerTesting):
 
             # doversion + write test
             bpy.ops.wm.open_mainfile('EXEC_DEFAULT', filepath=filepath_layers)
+            self.rename_collections()
             bpy.ops.wm.save_mainfile('EXEC_DEFAULT', filepath=filepath_doversion)
 
             datas = query_scene(filepath_doversion, 'Main', data_callbacks)
@@ -54,6 +55,7 @@ class UnitTesting(RenderLayerTesting):
             if do_read:
                 # read test, simply open and save the file
                 bpy.ops.wm.open_mainfile('EXEC_DEFAULT', filepath=filepath_doversion)
+                self.rename_collections()
                 bpy.ops.wm.save_mainfile('EXEC_DEFAULT', filepath=filepath_saved)
 
                 datas = query_scene(filepath_saved, 'Main', data_callbacks)
index da367ac3818ee762282c06cd719321fcf125fcec..843df22dd7a0b3c2d2da5e2d8b291e7b98ba0f76 100644 (file)
@@ -29,6 +29,7 @@ class UnitTesting(RenderLayerTesting):
 
             # open file
             bpy.ops.wm.open_mainfile('EXEC_DEFAULT', filepath=filepath_layers)
+            self.rename_collections()
 
             # create sub-collections
             three_b = bpy.data.objects.get('T.3b')