Rename any instance of scene layer or render layer in code with view layer
[blender.git] / tests / python / view_layer / test_collection_rename.py
1 # ############################################################
2 # Importing - Same For All Render Layer Tests
3 # ############################################################
4
5 import unittest
6 import os
7 import sys
8
9 from view_layer_common import *
10
11
12 # ############################################################
13 # Testing
14 # ############################################################
15
16 class UnitTesting(ViewLayerTesting):
17     def setup_family(self):
18         import bpy
19         scene = bpy.context.scene
20
21         # Just add a bunch of collections on which we can do various tests.
22         grandma = scene.master_collection.collections.new('grandma')
23         grandpa = scene.master_collection.collections.new('grandpa')
24         mom = grandma.collections.new('mom')
25         son = mom.collections.new('son')
26         daughter = mom.collections.new('daughter')
27         uncle = grandma.collections.new('uncle')
28         cousin = uncle.collections.new('cousin')
29
30         lookup = {c.name: c for c in (grandma, grandpa, mom, son, daughter, uncle, cousin)}
31         return lookup
32
33     def test_rename_a(self):
34         family = self.setup_family()
35
36         family['mom'].name = family['daughter'].name
37         self.assertNotEqual(family['mom'].name, family['daughter'].name)
38
39     def test_rename_b(self):
40         family = self.setup_family()
41
42         family['grandma'].name = family['grandpa'].name
43         self.assertNotEqual(family['grandma'].name, family['grandpa'].name)
44
45     def test_rename_c(self):
46         family = self.setup_family()
47
48         family['cousin'].name = family['daughter'].name
49         self.assertNotEqual(family['cousin'].name, family['daughter'].name)
50
51     def test_rename_d(self):
52         family = self.setup_family()
53
54         family['son'].name = family['daughter'].name
55         self.assertNotEqual(family['son'].name, family['daughter'].name)
56
57     def test_add_equal_name_a(self):
58         family = self.setup_family()
59
60         other_daughter = family['mom'].collections.new(family['daughter'].name)
61         self.assertNotEqual(other_daughter.name, family['daughter'].name)
62
63     def test_add_equal_name_b(self):
64         family = self.setup_family()
65
66         other_aunt = family['grandma'].collections.new(family['daughter'].name)
67         self.assertNotEqual(other_aunt.name, family['daughter'].name)
68
69
70 # ############################################################
71 # Main - Same For All Render Layer Tests
72 # ############################################################
73
74 if __name__ == '__main__':
75     UnitTesting._extra_arguments = setup_extra_arguments(__file__)
76     unittest.main()