[Bf-blender-cvs] [eae6e02] render-layers: unittest: active_collection_index

Dalai Felinto noreply at git.blender.org
Fri Dec 23 19:26:04 CET 2016


Commit: eae6e02759efa09beceb3bc5380ab5ccda4b9070
Author: Dalai Felinto
Date:   Fri Dec 23 17:38:36 2016 +0100
Branches: render-layers
https://developer.blender.org/rBeae6e02759efa09beceb3bc5380ab5ccda4b9070

unittest: active_collection_index

===================================================================

M	tests/python/bl_render_layer.py

===================================================================

diff --git a/tests/python/bl_render_layer.py b/tests/python/bl_render_layer.py
index a7ecd1e..3d15b09 100644
--- a/tests/python/bl_render_layer.py
+++ b/tests/python/bl_render_layer.py
@@ -601,6 +601,50 @@ class UnitsTesting(unittest.TestCase):
         filepath_json = os.path.join(ROOT, 'layers_layer_collection_unlink.json')
         self.do_layer_linking(filepath_json, 'COLLECTION_UNLINK')
 
+    def test_active_collection(self):
+        """
+        See if active collection index is working
+        layer.collections.active_index works recursively
+        """
+        import bpy
+        import os
+
+        ROOT = self.get_root()
+        filepath_layers = os.path.join(ROOT, 'layers.blend')
+
+        # open file
+        bpy.ops.wm.open_mainfile('EXEC_DEFAULT', filepath=filepath_layers)
+
+        # create sub-collections
+        three_b = bpy.data.objects.get('T.3b')
+        three_c = bpy.data.objects.get('T.3c')
+
+        scene = bpy.context.scene
+        subzero = scene.master_collection.collections['1'].collections.new('sub-zero')
+        scorpion = subzero.collections.new('scorpion')
+        subzero.objects.link(three_b)
+        scorpion.objects.link(three_c)
+        layer = scene.render_layers.new('Fresh new Layer')
+        layer.collections.link(subzero)
+
+        lookup = [
+                'Master Collection',
+                '1',
+                'sub-zero',
+                'scorpion',
+                '2',
+                '3',
+                '4',
+                '5',
+                'sub-zero',
+                'scorpion']
+
+        for i, name in enumerate(lookup):
+            layer.collections.active_index = i
+            self.assertTrue(name == layer.collections.active.name,
+                    "Collection index mismatch: [{0}] : {1} != {2}".format(
+                        i, name, layer.collections.active.name))
+
 
 # ############################################################
 # Main




More information about the Bf-blender-cvs mailing list