Rename any instance of scene layer or render layer in code with view layer
The RenderResult struct still has a listbase of RenderLayer, but that's ok since this is strictly for rendering. * Subversion bump (to 2.80.2) * DNA low level doversion (renames) - only for .blend created since 2.80 started Note: We can't use DNA_struct_elem_find or get file version in init_structDNA, so we are manually iterating over the array of the SDNA elements instead. Note 2: This doversion change with renames can be reverted in a few months. But so far it's required for 2.8 files created between October 2016 and now. Reviewers: campbellbarton, sergey Differential Revision: https://developer.blender.org/D2927
This commit is contained in:
175
tests/python/view_layer/CMakeLists.txt
Normal file
175
tests/python/view_layer/CMakeLists.txt
Normal file
@@ -0,0 +1,175 @@
|
||||
# ***** BEGIN GPL LICENSE BLOCK *****
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# Contributor(s): Jacques Beaurain, Dalai Felinto.
|
||||
#
|
||||
# ***** END GPL LICENSE BLOCK *****
|
||||
|
||||
# --env-system-scripts allows to run without the install target.
|
||||
|
||||
# Use '--write-blend=/tmp/test.blend' to view output
|
||||
|
||||
set(TEST_SRC_DIR ${CMAKE_SOURCE_DIR}/../lib/tests)
|
||||
set(TEST_OUT_DIR ${CMAKE_BINARY_DIR}/tests)
|
||||
|
||||
# ugh, any better way to do this on testing only?
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_OUT_DIR})
|
||||
|
||||
#~ if(NOT IS_DIRECTORY ${TEST_SRC_DIR})
|
||||
#~ message(FATAL_ERROR "CMake test directory not found!")
|
||||
#~ endif()
|
||||
|
||||
# all calls to blender use this
|
||||
if(APPLE)
|
||||
if(${CMAKE_GENERATOR} MATCHES "Xcode")
|
||||
set(TEST_BLENDER_EXE ${EXECUTABLE_OUTPUT_PATH}/Debug/blender.app/Contents/MacOS/blender)
|
||||
else()
|
||||
set(TEST_BLENDER_EXE ${EXECUTABLE_OUTPUT_PATH}/blender.app/Contents/MacOS/blender)
|
||||
endif()
|
||||
else()
|
||||
set(TEST_BLENDER_EXE ${EXECUTABLE_OUTPUT_PATH}/blender)
|
||||
endif()
|
||||
|
||||
# for testing with valgrind prefix: valgrind --track-origins=yes --error-limit=no
|
||||
set(TEST_BLENDER_EXE ${TEST_BLENDER_EXE} --background -noaudio --factory-startup --env-system-scripts ${CMAKE_SOURCE_DIR}/release/scripts)
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
macro(VIEW_LAYER_TEST test_name)
|
||||
# Adds ${CMAKE_CURRENT_LIST_DIR} to sys.path so that the tests can import
|
||||
# things from view_layer_common.py
|
||||
add_test(view_layer_${test_name} ${TEST_BLENDER_EXE}
|
||||
--python-expr "import sys; sys.path.append('${CMAKE_CURRENT_LIST_DIR}')"
|
||||
--python-exit-code 1
|
||||
--python ${CMAKE_CURRENT_LIST_DIR}/test_${test_name}.py --
|
||||
--testdir="${TEST_SRC_DIR}/layers"
|
||||
)
|
||||
endmacro()
|
||||
|
||||
VIEW_LAYER_TEST(active_collection)
|
||||
VIEW_LAYER_TEST(collection_rename)
|
||||
VIEW_LAYER_TEST(evaluation_render_settings_a)
|
||||
VIEW_LAYER_TEST(evaluation_render_settings_b)
|
||||
VIEW_LAYER_TEST(evaluation_render_settings_c)
|
||||
VIEW_LAYER_TEST(evaluation_render_settings_d)
|
||||
VIEW_LAYER_TEST(evaluation_render_settings_e)
|
||||
VIEW_LAYER_TEST(evaluation_render_settings_f)
|
||||
VIEW_LAYER_TEST(evaluation_render_settings_g)
|
||||
VIEW_LAYER_TEST(evaluation_render_settings_h)
|
||||
VIEW_LAYER_TEST(evaluation_render_settings_i)
|
||||
VIEW_LAYER_TEST(evaluation_visibility_a)
|
||||
VIEW_LAYER_TEST(evaluation_visibility_b)
|
||||
VIEW_LAYER_TEST(evaluation_visibility_c)
|
||||
VIEW_LAYER_TEST(evaluation_visibility_d)
|
||||
VIEW_LAYER_TEST(evaluation_visibility_e)
|
||||
VIEW_LAYER_TEST(evaluation_visibility_f)
|
||||
VIEW_LAYER_TEST(evaluation_visibility_g)
|
||||
VIEW_LAYER_TEST(evaluation_visibility_h)
|
||||
VIEW_LAYER_TEST(evaluation_visibility_i)
|
||||
VIEW_LAYER_TEST(evaluation_selectability_a)
|
||||
VIEW_LAYER_TEST(evaluation_selectability_b)
|
||||
VIEW_LAYER_TEST(evaluation_selectability_c)
|
||||
VIEW_LAYER_TEST(evaluation_selectability_d)
|
||||
VIEW_LAYER_TEST(evaluation_selectability_e)
|
||||
VIEW_LAYER_TEST(evaluation_selectability_f)
|
||||
VIEW_LAYER_TEST(object_add_cylinder)
|
||||
VIEW_LAYER_TEST(object_add_empty)
|
||||
VIEW_LAYER_TEST(object_add_torus)
|
||||
VIEW_LAYER_TEST(object_add_no_collection_cylinder)
|
||||
VIEW_LAYER_TEST(object_add_no_collection_empty)
|
||||
VIEW_LAYER_TEST(object_add_no_collection_torus)
|
||||
VIEW_LAYER_TEST(object_copy)
|
||||
VIEW_LAYER_TEST(object_delete_a)
|
||||
VIEW_LAYER_TEST(object_delete_b)
|
||||
VIEW_LAYER_TEST(object_link_a)
|
||||
VIEW_LAYER_TEST(object_link_b)
|
||||
VIEW_LAYER_TEST(object_link_c)
|
||||
VIEW_LAYER_TEST(operator_context)
|
||||
VIEW_LAYER_TEST(move_above_below_scene_collection_a)
|
||||
VIEW_LAYER_TEST(move_above_below_scene_collection_b)
|
||||
VIEW_LAYER_TEST(move_above_below_scene_collection_c)
|
||||
VIEW_LAYER_TEST(move_above_below_scene_collection_d)
|
||||
VIEW_LAYER_TEST(move_above_below_scene_collection_e)
|
||||
VIEW_LAYER_TEST(move_above_below_scene_collection_f)
|
||||
VIEW_LAYER_TEST(move_above_below_scene_collection_g)
|
||||
VIEW_LAYER_TEST(move_above_below_scene_collection_h)
|
||||
VIEW_LAYER_TEST(move_above_below_scene_collection_i)
|
||||
VIEW_LAYER_TEST(move_above_below_scene_collection_sync_a)
|
||||
VIEW_LAYER_TEST(move_above_below_scene_collection_sync_b)
|
||||
VIEW_LAYER_TEST(move_above_below_scene_collection_sync_c)
|
||||
VIEW_LAYER_TEST(move_above_below_scene_collection_sync_d)
|
||||
VIEW_LAYER_TEST(move_above_below_scene_collection_sync_e)
|
||||
VIEW_LAYER_TEST(move_above_below_scene_collection_sync_f)
|
||||
VIEW_LAYER_TEST(move_above_below_scene_collection_sync_g)
|
||||
VIEW_LAYER_TEST(move_above_below_scene_collection_sync_h)
|
||||
VIEW_LAYER_TEST(move_above_below_scene_collection_sync_i)
|
||||
VIEW_LAYER_TEST(move_into_scene_collection_a)
|
||||
VIEW_LAYER_TEST(move_into_scene_collection_b)
|
||||
VIEW_LAYER_TEST(move_into_scene_collection_c)
|
||||
VIEW_LAYER_TEST(move_into_scene_collection_d)
|
||||
VIEW_LAYER_TEST(move_into_scene_collection_e)
|
||||
VIEW_LAYER_TEST(move_into_scene_collection_f)
|
||||
VIEW_LAYER_TEST(move_into_scene_collection_g)
|
||||
VIEW_LAYER_TEST(move_into_scene_collection_h)
|
||||
VIEW_LAYER_TEST(move_into_scene_collection_i)
|
||||
VIEW_LAYER_TEST(move_into_scene_collection_j)
|
||||
VIEW_LAYER_TEST(move_into_scene_collection_k)
|
||||
VIEW_LAYER_TEST(move_into_scene_collection_l)
|
||||
VIEW_LAYER_TEST(move_into_scene_collection_sync_a)
|
||||
VIEW_LAYER_TEST(move_into_scene_collection_sync_b)
|
||||
VIEW_LAYER_TEST(move_into_scene_collection_sync_c)
|
||||
VIEW_LAYER_TEST(move_into_scene_collection_sync_d)
|
||||
VIEW_LAYER_TEST(move_into_scene_collection_sync_e)
|
||||
VIEW_LAYER_TEST(move_into_scene_collection_sync_f)
|
||||
VIEW_LAYER_TEST(move_into_scene_collection_sync_g)
|
||||
VIEW_LAYER_TEST(move_into_scene_collection_sync_h)
|
||||
VIEW_LAYER_TEST(move_into_scene_collection_sync_i)
|
||||
VIEW_LAYER_TEST(move_into_scene_collection_sync_j)
|
||||
VIEW_LAYER_TEST(move_into_scene_collection_sync_k)
|
||||
VIEW_LAYER_TEST(move_into_scene_collection_sync_l)
|
||||
VIEW_LAYER_TEST(move_above_below_layer_collection_a)
|
||||
VIEW_LAYER_TEST(move_above_below_layer_collection_b)
|
||||
VIEW_LAYER_TEST(move_above_below_layer_collection_c)
|
||||
VIEW_LAYER_TEST(move_above_below_layer_collection_d)
|
||||
VIEW_LAYER_TEST(move_above_below_layer_collection_e)
|
||||
VIEW_LAYER_TEST(move_above_below_layer_collection_f)
|
||||
VIEW_LAYER_TEST(move_above_below_layer_collection_g)
|
||||
VIEW_LAYER_TEST(move_above_below_layer_collection_h)
|
||||
VIEW_LAYER_TEST(move_above_below_layer_collection_i)
|
||||
VIEW_LAYER_TEST(move_above_below_layer_collection_j)
|
||||
VIEW_LAYER_TEST(move_above_below_layer_collection_k)
|
||||
VIEW_LAYER_TEST(move_above_below_layer_collection_l)
|
||||
VIEW_LAYER_TEST(move_into_layer_collection_a)
|
||||
VIEW_LAYER_TEST(move_into_layer_collection_b)
|
||||
VIEW_LAYER_TEST(move_into_layer_collection_c)
|
||||
VIEW_LAYER_TEST(move_into_layer_collection_d)
|
||||
VIEW_LAYER_TEST(move_into_layer_collection_e)
|
||||
VIEW_LAYER_TEST(move_into_layer_collection_f)
|
||||
VIEW_LAYER_TEST(move_into_layer_collection_g)
|
||||
VIEW_LAYER_TEST(move_into_layer_collection_h)
|
||||
VIEW_LAYER_TEST(move_into_layer_collection_i)
|
||||
VIEW_LAYER_TEST(move_into_layer_collection_j)
|
||||
VIEW_LAYER_TEST(layer_linking)
|
||||
VIEW_LAYER_TEST(layer_syncing)
|
||||
VIEW_LAYER_TEST(scene_copy_a)
|
||||
VIEW_LAYER_TEST(scene_copy_b)
|
||||
VIEW_LAYER_TEST(scene_copy_c)
|
||||
VIEW_LAYER_TEST(scene_copy_d)
|
||||
VIEW_LAYER_TEST(scene_copy_e)
|
||||
VIEW_LAYER_TEST(scene_copy_f)
|
||||
VIEW_LAYER_TEST(scene_delete)
|
||||
VIEW_LAYER_TEST(scene_write_read)
|
||||
70
tests/python/view_layer/test_active_collection.py
Normal file
70
tests/python/view_layer/test_active_collection.py
Normal file
@@ -0,0 +1,70 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
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)
|
||||
self.rename_collections()
|
||||
|
||||
# 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.view_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.assertEqual(
|
||||
name, layer.collections.active.name,
|
||||
"Collection index mismatch: [{0}] : {1} != {2}".format(
|
||||
i, name, layer.collections.active.name))
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
76
tests/python/view_layer/test_collection_rename.py
Normal file
76
tests/python/view_layer/test_collection_rename.py
Normal file
@@ -0,0 +1,76 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def setup_family(self):
|
||||
import bpy
|
||||
scene = bpy.context.scene
|
||||
|
||||
# Just add a bunch of collections on which we can do various tests.
|
||||
grandma = scene.master_collection.collections.new('grandma')
|
||||
grandpa = scene.master_collection.collections.new('grandpa')
|
||||
mom = grandma.collections.new('mom')
|
||||
son = mom.collections.new('son')
|
||||
daughter = mom.collections.new('daughter')
|
||||
uncle = grandma.collections.new('uncle')
|
||||
cousin = uncle.collections.new('cousin')
|
||||
|
||||
lookup = {c.name: c for c in (grandma, grandpa, mom, son, daughter, uncle, cousin)}
|
||||
return lookup
|
||||
|
||||
def test_rename_a(self):
|
||||
family = self.setup_family()
|
||||
|
||||
family['mom'].name = family['daughter'].name
|
||||
self.assertNotEqual(family['mom'].name, family['daughter'].name)
|
||||
|
||||
def test_rename_b(self):
|
||||
family = self.setup_family()
|
||||
|
||||
family['grandma'].name = family['grandpa'].name
|
||||
self.assertNotEqual(family['grandma'].name, family['grandpa'].name)
|
||||
|
||||
def test_rename_c(self):
|
||||
family = self.setup_family()
|
||||
|
||||
family['cousin'].name = family['daughter'].name
|
||||
self.assertNotEqual(family['cousin'].name, family['daughter'].name)
|
||||
|
||||
def test_rename_d(self):
|
||||
family = self.setup_family()
|
||||
|
||||
family['son'].name = family['daughter'].name
|
||||
self.assertNotEqual(family['son'].name, family['daughter'].name)
|
||||
|
||||
def test_add_equal_name_a(self):
|
||||
family = self.setup_family()
|
||||
|
||||
other_daughter = family['mom'].collections.new(family['daughter'].name)
|
||||
self.assertNotEqual(other_daughter.name, family['daughter'].name)
|
||||
|
||||
def test_add_equal_name_b(self):
|
||||
family = self.setup_family()
|
||||
|
||||
other_aunt = family['grandma'].collections.new(family['daughter'].name)
|
||||
self.assertNotEqual(other_aunt.name, family['daughter'].name)
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
33
tests/python/view_layer/test_evaluation_render_settings_a.py
Normal file
33
tests/python/view_layer/test_evaluation_render_settings_a.py
Normal file
@@ -0,0 +1,33 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_render_settings(self):
|
||||
"""
|
||||
See if the depsgraph evaluation is correct
|
||||
"""
|
||||
clay = Clay()
|
||||
self.assertEqual(clay.get('object', 'matcap_icon'), '01')
|
||||
clay.set('scene', 'matcap_icon', '05')
|
||||
self.assertEqual(clay.get('object', 'matcap_icon'), '05')
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
34
tests/python/view_layer/test_evaluation_render_settings_b.py
Normal file
34
tests/python/view_layer/test_evaluation_render_settings_b.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_render_settings(self):
|
||||
"""
|
||||
See if the depsgraph evaluation is correct
|
||||
"""
|
||||
clay = Clay()
|
||||
self.assertEqual(clay.get('object', 'matcap_icon'), '01')
|
||||
clay.set('scene', 'matcap_icon', '05')
|
||||
clay.set('grandma', 'matcap_icon', '03')
|
||||
self.assertEqual(clay.get('object', 'matcap_icon'), '03')
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
33
tests/python/view_layer/test_evaluation_render_settings_c.py
Normal file
33
tests/python/view_layer/test_evaluation_render_settings_c.py
Normal file
@@ -0,0 +1,33 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_render_settings(self):
|
||||
"""
|
||||
See if the depsgraph evaluation is correct
|
||||
"""
|
||||
clay = Clay()
|
||||
self.assertEqual(clay.get('object', 'matcap_icon'), '01')
|
||||
clay.set('mom', 'matcap_icon', '02')
|
||||
self.assertEqual(clay.get('object', 'matcap_icon'), '02')
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
33
tests/python/view_layer/test_evaluation_render_settings_d.py
Normal file
33
tests/python/view_layer/test_evaluation_render_settings_d.py
Normal file
@@ -0,0 +1,33 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_render_settings(self):
|
||||
"""
|
||||
See if the depsgraph evaluation is correct
|
||||
"""
|
||||
clay = Clay()
|
||||
self.assertEqual(clay.get('object', 'matcap_icon'), '01')
|
||||
clay.set('kid', 'matcap_icon', '05')
|
||||
self.assertEqual(clay.get('object', 'matcap_icon'), '05')
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
34
tests/python/view_layer/test_evaluation_render_settings_e.py
Normal file
34
tests/python/view_layer/test_evaluation_render_settings_e.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_render_settings(self):
|
||||
"""
|
||||
See if the depsgraph evaluation is correct
|
||||
"""
|
||||
clay = Clay()
|
||||
self.assertEqual(clay.get('object', 'matcap_icon'), '01')
|
||||
clay.set('grandma', 'matcap_icon', '04')
|
||||
clay.set('kid', 'matcap_icon', '05')
|
||||
self.assertEqual(clay.get('object', 'matcap_icon'), '05')
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
35
tests/python/view_layer/test_evaluation_render_settings_f.py
Normal file
35
tests/python/view_layer/test_evaluation_render_settings_f.py
Normal file
@@ -0,0 +1,35 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_render_settings(self):
|
||||
"""
|
||||
See if the depsgraph evaluation is correct
|
||||
"""
|
||||
clay = Clay(extra_kid_layer=True)
|
||||
self.assertEqual(clay.get('object', 'matcap_icon'), '01')
|
||||
|
||||
clay.set('scene', 'matcap_icon', '05')
|
||||
clay.set('extra', 'matcap_icon', '07')
|
||||
self.assertEqual(clay.get('object', 'matcap_icon'), '07')
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
35
tests/python/view_layer/test_evaluation_render_settings_g.py
Normal file
35
tests/python/view_layer/test_evaluation_render_settings_g.py
Normal file
@@ -0,0 +1,35 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_render_settings(self):
|
||||
"""
|
||||
See if the depsgraph evaluation is correct
|
||||
"""
|
||||
clay = Clay(extra_kid_layer=True)
|
||||
self.assertEqual(clay.get('object', 'matcap_icon'), '01')
|
||||
|
||||
clay.set('mom', 'matcap_icon', '02')
|
||||
clay.set('extra', 'matcap_icon', '06')
|
||||
self.assertEqual(clay.get('object', 'matcap_icon'), '06')
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
35
tests/python/view_layer/test_evaluation_render_settings_h.py
Normal file
35
tests/python/view_layer/test_evaluation_render_settings_h.py
Normal file
@@ -0,0 +1,35 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_render_settings(self):
|
||||
"""
|
||||
See if the depsgraph evaluation is correct
|
||||
"""
|
||||
clay = Clay(extra_kid_layer=True)
|
||||
self.assertEqual(clay.get('object', 'matcap_icon'), '01')
|
||||
|
||||
clay.set('kid', 'matcap_icon', '02')
|
||||
clay.set('extra', 'matcap_icon', '04')
|
||||
self.assertEqual(clay.get('object', 'matcap_icon'), '04')
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
35
tests/python/view_layer/test_evaluation_render_settings_i.py
Normal file
35
tests/python/view_layer/test_evaluation_render_settings_i.py
Normal file
@@ -0,0 +1,35 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_render_settings(self):
|
||||
"""
|
||||
See if the depsgraph evaluation is correct
|
||||
"""
|
||||
clay = Clay(extra_kid_layer=True)
|
||||
self.assertEqual(clay.get('object', 'matcap_icon'), '01')
|
||||
|
||||
clay.set('mom', 'matcap_icon', '02')
|
||||
self.assertEqual(clay.get('extra', 'matcap_icon'), '01')
|
||||
self.assertEqual(clay.get('object', 'matcap_icon'), '02')
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
54
tests/python/view_layer/test_evaluation_selectability_a.py
Normal file
54
tests/python/view_layer/test_evaluation_selectability_a.py
Normal file
@@ -0,0 +1,54 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_selectability(self):
|
||||
"""
|
||||
See if the depsgraph evaluation is correct
|
||||
"""
|
||||
import bpy
|
||||
|
||||
scene = bpy.context.scene
|
||||
workspace = bpy.context.workspace
|
||||
cube = bpy.data.objects.new('guinea pig', bpy.data.meshes.new('mesh'))
|
||||
|
||||
layer = scene.view_layers.new('Selectability Test')
|
||||
layer.collections.unlink(layer.collections[0])
|
||||
scene.view_layers.active = layer
|
||||
workspace.view_layer = layer
|
||||
|
||||
scene_collection_mom = scene.master_collection.collections.new("Mom")
|
||||
scene_collection_kid = scene_collection_mom.collections.new("Kid")
|
||||
|
||||
scene_collection_kid.objects.link(cube)
|
||||
|
||||
layer_collection_mom = layer.collections.link(scene_collection_mom)
|
||||
layer_collection_kid = layer.collections.link(scene_collection_kid)
|
||||
|
||||
layer_collection_mom.hide = True
|
||||
bpy.context.scene.update() # update depsgraph
|
||||
cube.select_set('SELECT')
|
||||
|
||||
self.assertTrue(cube.visible_get(), "Cube should be visible")
|
||||
self.assertTrue(cube.select_get(), "Cube should be selected")
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
56
tests/python/view_layer/test_evaluation_selectability_b.py
Normal file
56
tests/python/view_layer/test_evaluation_selectability_b.py
Normal file
@@ -0,0 +1,56 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_selectability(self):
|
||||
"""
|
||||
See if the depsgraph evaluation is correct
|
||||
"""
|
||||
import bpy
|
||||
|
||||
scene = bpy.context.scene
|
||||
workspace = bpy.context.workspace
|
||||
cube = bpy.data.objects.new('guinea pig', bpy.data.meshes.new('mesh'))
|
||||
|
||||
layer = scene.view_layers.new('Selectability Test')
|
||||
layer.collections.unlink(layer.collections[0])
|
||||
scene.view_layers.active = layer
|
||||
workspace.view_layer = layer
|
||||
|
||||
scene_collection_mom = scene.master_collection.collections.new("Mom")
|
||||
scene_collection_kid = scene_collection_mom.collections.new("Kid")
|
||||
|
||||
scene_collection_kid.objects.link(cube)
|
||||
|
||||
layer_collection_mom = layer.collections.link(scene_collection_mom)
|
||||
layer_collection_kid = layer.collections.link(scene_collection_kid)
|
||||
bpy.context.scene.update() # update depsgraph
|
||||
cube.select_set('SELECT')
|
||||
|
||||
layer_collection_mom.collections[layer_collection_kid.name].hide = True
|
||||
layer_collection_kid.hide = True
|
||||
|
||||
bpy.context.scene.update() # update depsgraph
|
||||
self.assertFalse(cube.visible_get(), "Cube should be invisible")
|
||||
self.assertFalse(cube.select_get(), "Cube should be unselected")
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
54
tests/python/view_layer/test_evaluation_selectability_c.py
Normal file
54
tests/python/view_layer/test_evaluation_selectability_c.py
Normal file
@@ -0,0 +1,54 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_selectability(self):
|
||||
"""
|
||||
See if the depsgraph evaluation is correct
|
||||
"""
|
||||
import bpy
|
||||
|
||||
scene = bpy.context.scene
|
||||
workspace = bpy.context.workspace
|
||||
cube = bpy.data.objects.new('guinea pig', bpy.data.meshes.new('mesh'))
|
||||
|
||||
layer = scene.view_layers.new('Selectability Test')
|
||||
layer.collections.unlink(layer.collections[0])
|
||||
scene.view_layers.active = layer
|
||||
workspace.view_layer = layer
|
||||
|
||||
scene_collection_mom = scene.master_collection.collections.new("Mom")
|
||||
scene_collection_kid = scene_collection_mom.collections.new("Kid")
|
||||
|
||||
scene_collection_kid.objects.link(cube)
|
||||
|
||||
layer_collection_mom = layer.collections.link(scene_collection_mom)
|
||||
layer_collection_kid = layer.collections.link(scene_collection_kid)
|
||||
|
||||
layer_collection_mom.hide = False
|
||||
bpy.context.scene.update() # update depsgraph
|
||||
cube.select_set('SELECT')
|
||||
|
||||
self.assertTrue(cube.visible_get(), "Cube should be visible")
|
||||
self.assertTrue(cube.select_get(), "Cube should be selected")
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
57
tests/python/view_layer/test_evaluation_selectability_d.py
Normal file
57
tests/python/view_layer/test_evaluation_selectability_d.py
Normal file
@@ -0,0 +1,57 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_selectability(self):
|
||||
"""
|
||||
See if the depsgraph evaluation is correct
|
||||
"""
|
||||
import bpy
|
||||
|
||||
scene = bpy.context.scene
|
||||
workspace = bpy.context.workspace
|
||||
cube = bpy.data.objects.new('guinea pig', bpy.data.meshes.new('mesh'))
|
||||
|
||||
layer = scene.view_layers.new('Selectability Test')
|
||||
layer.collections.unlink(layer.collections[0])
|
||||
scene.view_layers.active = layer
|
||||
workspace.view_layer = layer
|
||||
|
||||
scene_collection_mom = scene.master_collection.collections.new("Mom")
|
||||
scene_collection_kid = scene_collection_mom.collections.new("Kid")
|
||||
|
||||
scene_collection_kid.objects.link(cube)
|
||||
|
||||
layer_collection_mom = layer.collections.link(scene_collection_mom)
|
||||
layer_collection_kid = layer.collections.link(scene_collection_kid)
|
||||
|
||||
layer_collection_mom.hide = False
|
||||
bpy.context.scene.update() # update depsgraph
|
||||
|
||||
cube.select_set('SELECT')
|
||||
layer_collection_mom.collections[layer_collection_kid.name].hide_select = True
|
||||
|
||||
bpy.context.scene.update() # update depsgraph
|
||||
self.assertTrue(cube.visible_get(), "Cube should be visible")
|
||||
self.assertTrue(cube.select_get(), "Cube should be selected")
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
56
tests/python/view_layer/test_evaluation_selectability_e.py
Normal file
56
tests/python/view_layer/test_evaluation_selectability_e.py
Normal file
@@ -0,0 +1,56 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_selectability(self):
|
||||
"""
|
||||
See if the depsgraph evaluation is correct
|
||||
"""
|
||||
import bpy
|
||||
|
||||
scene = bpy.context.scene
|
||||
workspace = bpy.context.workspace
|
||||
cube = bpy.data.objects.new('guinea pig', bpy.data.meshes.new('mesh'))
|
||||
|
||||
layer = scene.view_layers.new('Selectability Test')
|
||||
layer.collections.unlink(layer.collections[0])
|
||||
scene.view_layers.active = layer
|
||||
workspace.view_layer = layer
|
||||
|
||||
scene_collection_mom = scene.master_collection.collections.new("Mom")
|
||||
scene_collection_kid = scene_collection_mom.collections.new("Kid")
|
||||
|
||||
scene_collection_kid.objects.link(cube)
|
||||
|
||||
layer_collection_mom = layer.collections.link(scene_collection_mom)
|
||||
layer_collection_kid = layer.collections.link(scene_collection_kid)
|
||||
|
||||
layer_collection_mom.hide = False
|
||||
cube.select_set('SELECT')
|
||||
layer_collection_mom.collections[layer_collection_kid.name].hide_select = True
|
||||
layer_collection_kid.hide = True
|
||||
|
||||
bpy.context.scene.update() # update depsgraph
|
||||
self.assertTrue(cube.visible_get(), "Cube should be visible")
|
||||
self.assertFalse(cube.select_get(), "Cube should be unselected")
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
43
tests/python/view_layer/test_evaluation_selectability_f.py
Normal file
43
tests/python/view_layer/test_evaluation_selectability_f.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_selectability(self):
|
||||
import bpy
|
||||
scene = bpy.context.scene
|
||||
|
||||
cube = bpy.data.objects.new('guinea pig', bpy.data.meshes.new('mesh'))
|
||||
scene_collection = scene.master_collection.collections.new('collection')
|
||||
layer_collection = scene.view_layers.active.collections.link(scene_collection)
|
||||
|
||||
bpy.context.scene.update() # update depsgraph
|
||||
|
||||
scene_collection.objects.link(cube)
|
||||
|
||||
self.assertFalse(layer_collection.hide)
|
||||
self.assertFalse(layer_collection.hide_select)
|
||||
|
||||
bpy.context.scene.update() # update depsgraph
|
||||
cube.select_set(action='SELECT')
|
||||
self.assertTrue(cube.select_get())
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
54
tests/python/view_layer/test_evaluation_visibility_a.py
Normal file
54
tests/python/view_layer/test_evaluation_visibility_a.py
Normal file
@@ -0,0 +1,54 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_visibility(self):
|
||||
"""
|
||||
See if the depsgraph evaluation is correct
|
||||
"""
|
||||
import bpy
|
||||
|
||||
scene = bpy.context.scene
|
||||
workspace = bpy.context.workspace
|
||||
cube = bpy.data.objects.new('guinea pig', bpy.data.meshes.new('mesh'))
|
||||
|
||||
layer = scene.view_layers.new('Visibility Test')
|
||||
layer.collections.unlink(layer.collections[0])
|
||||
scene.view_layers.active = layer
|
||||
workspace.view_layer = layer
|
||||
|
||||
scene_collection_mom = scene.master_collection.collections.new("Mom")
|
||||
scene_collection_kid = scene.master_collection.collections.new("Kid")
|
||||
|
||||
scene_collection_mom.objects.link(cube)
|
||||
scene_collection_kid.objects.link(cube)
|
||||
|
||||
layer_collection_mom = layer.collections.link(scene_collection_mom)
|
||||
layer_collection_kid = layer.collections.link(scene_collection_kid)
|
||||
|
||||
layer_collection_mom.hide = True
|
||||
layer_collection_kid.hide = False
|
||||
|
||||
bpy.context.scene.update() # update depsgraph
|
||||
self.assertTrue(cube.visible_get(), "Object should be visible")
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
54
tests/python/view_layer/test_evaluation_visibility_b.py
Normal file
54
tests/python/view_layer/test_evaluation_visibility_b.py
Normal file
@@ -0,0 +1,54 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_visibility(self):
|
||||
"""
|
||||
See if the depsgraph evaluation is correct
|
||||
"""
|
||||
import bpy
|
||||
|
||||
scene = bpy.context.scene
|
||||
workspace = bpy.context.workspace
|
||||
cube = bpy.data.objects.new('guinea pig', bpy.data.meshes.new('mesh'))
|
||||
|
||||
layer = scene.view_layers.new('Visibility Test')
|
||||
layer.collections.unlink(layer.collections[0])
|
||||
scene.view_layers.active = layer
|
||||
workspace.view_layer = layer
|
||||
|
||||
scene_collection_mom = scene.master_collection.collections.new("Mom")
|
||||
scene_collection_kid = scene_collection_mom.collections.new("Kid")
|
||||
|
||||
scene_collection_kid.objects.link(cube)
|
||||
|
||||
layer_collection_mom = layer.collections.link(scene_collection_mom)
|
||||
layer_collection_kid = layer.collections.link(scene_collection_kid)
|
||||
|
||||
layer_collection_mom.hide = False
|
||||
layer_collection_mom.collections[layer_collection_kid.name].hide = True
|
||||
layer_collection_kid.hide = True
|
||||
|
||||
bpy.context.scene.update() # update depsgraph
|
||||
self.assertFalse(cube.visible_get(), "Object should be invisible")
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
54
tests/python/view_layer/test_evaluation_visibility_c.py
Normal file
54
tests/python/view_layer/test_evaluation_visibility_c.py
Normal file
@@ -0,0 +1,54 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_visibility(self):
|
||||
"""
|
||||
See if the depsgraph evaluation is correct
|
||||
"""
|
||||
import bpy
|
||||
|
||||
scene = bpy.context.scene
|
||||
workspace = bpy.context.workspace
|
||||
cube = bpy.data.objects.new('guinea pig', bpy.data.meshes.new('mesh'))
|
||||
|
||||
layer = scene.view_layers.new('Visibility Test')
|
||||
layer.collections.unlink(layer.collections[0])
|
||||
scene.view_layers.active = layer
|
||||
workspace.view_layer = layer
|
||||
|
||||
scene_collection_mom = scene.master_collection.collections.new("Mom")
|
||||
scene_collection_kid = scene_collection_mom.collections.new("Kid")
|
||||
|
||||
scene_collection_kid.objects.link(cube)
|
||||
|
||||
layer_collection_mom = layer.collections.link(scene_collection_mom)
|
||||
layer_collection_kid = layer.collections.link(scene_collection_kid)
|
||||
|
||||
layer_collection_mom.hide = False
|
||||
layer_collection_mom.collections[layer_collection_kid.name].hide = True
|
||||
layer_collection_kid.hide = False
|
||||
|
||||
bpy.context.scene.update() # update depsgraph
|
||||
self.assertTrue(cube.visible_get(), "Object should be visible")
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
51
tests/python/view_layer/test_evaluation_visibility_d.py
Normal file
51
tests/python/view_layer/test_evaluation_visibility_d.py
Normal file
@@ -0,0 +1,51 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_visibility(self):
|
||||
"""
|
||||
See if the depsgraph evaluation is correct
|
||||
"""
|
||||
import bpy
|
||||
|
||||
scene = bpy.context.scene
|
||||
workspace = bpy.context.workspace
|
||||
cube = bpy.data.objects.new('guinea pig', bpy.data.meshes.new('mesh'))
|
||||
|
||||
layer = scene.view_layers.new('Visibility Test')
|
||||
layer.collections.unlink(layer.collections[0])
|
||||
scene.view_layers.active = layer
|
||||
workspace.view_layer = layer
|
||||
|
||||
scene_collection_mom = scene.master_collection.collections.new("Mom")
|
||||
scene_collection_kid = scene_collection_mom.collections.new("Kid")
|
||||
|
||||
scene_collection_kid.objects.link(cube)
|
||||
|
||||
layer_collection_mom = layer.collections.link(scene_collection_mom)
|
||||
layer_collection_kid = layer.collections.link(scene_collection_kid)
|
||||
|
||||
layer_collection_mom.hide = False
|
||||
bpy.context.scene.update() # update depsgraph
|
||||
self.assertTrue(cube.visible_get(), "Object should be visible")
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
55
tests/python/view_layer/test_evaluation_visibility_e.py
Normal file
55
tests/python/view_layer/test_evaluation_visibility_e.py
Normal file
@@ -0,0 +1,55 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_visibility(self):
|
||||
"""
|
||||
See if the depsgraph evaluation is correct
|
||||
"""
|
||||
import bpy
|
||||
|
||||
scene = bpy.context.scene
|
||||
workspace = bpy.context.workspace
|
||||
cube = bpy.data.objects.new('guinea pig', bpy.data.meshes.new('mesh'))
|
||||
|
||||
layer = scene.view_layers.new('Visibility Test')
|
||||
layer.collections.unlink(layer.collections[0])
|
||||
scene.view_layers.active = layer
|
||||
workspace.view_layer = layer
|
||||
|
||||
scene_collection_mom = scene.master_collection.collections.new("Mom")
|
||||
scene_collection_kid = scene_collection_mom.collections.new("Kid")
|
||||
|
||||
scene_collection_mom.objects.link(cube)
|
||||
scene_collection_kid.objects.link(cube)
|
||||
|
||||
layer_collection_mom = layer.collections.link(scene_collection_mom)
|
||||
layer_collection_kid = layer.collections.link(scene_collection_kid)
|
||||
|
||||
layer_collection_mom.hide = False
|
||||
layer_collection_kid.hide = True
|
||||
|
||||
bpy.context.scene.update() # update depsgraph
|
||||
self.assertTrue(cube.visible_get(), "Object should be visible")
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
# XXX, above statement is not true, why skip the first argument?
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)[1:]
|
||||
unittest.main()
|
||||
55
tests/python/view_layer/test_evaluation_visibility_f.py
Normal file
55
tests/python/view_layer/test_evaluation_visibility_f.py
Normal file
@@ -0,0 +1,55 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_visibility(self):
|
||||
"""
|
||||
See if the depsgraph evaluation is correct
|
||||
"""
|
||||
import bpy
|
||||
|
||||
scene = bpy.context.scene
|
||||
workspace = bpy.context.workspace
|
||||
cube = bpy.data.objects.new('guinea pig', bpy.data.meshes.new('mesh'))
|
||||
|
||||
layer = scene.view_layers.new('Visibility Test')
|
||||
layer.collections.unlink(layer.collections[0])
|
||||
scene.view_layers.active = layer
|
||||
workspace.view_layer = layer
|
||||
|
||||
scene_collection_mom = scene.master_collection.collections.new("Mom")
|
||||
scene_collection_kid = scene_collection_mom.collections.new("Kid")
|
||||
|
||||
scene_collection_mom.objects.link(cube)
|
||||
scene_collection_kid.objects.link(cube)
|
||||
|
||||
layer_collection_mom = layer.collections.link(scene_collection_mom)
|
||||
layer_collection_kid = layer.collections.link(scene_collection_kid)
|
||||
|
||||
layer_collection_mom.hide = False
|
||||
layer_collection_mom.collections[layer_collection_kid.name].hide = True
|
||||
layer_collection_kid.hide = True
|
||||
|
||||
bpy.context.scene.update() # update depsgraph
|
||||
self.assertTrue(cube.visible_get(), "Object should be visible")
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
30
tests/python/view_layer/test_evaluation_visibility_g.py
Normal file
30
tests/python/view_layer/test_evaluation_visibility_g.py
Normal file
@@ -0,0 +1,30 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_visibility_empty(self):
|
||||
"""
|
||||
See if the depsgraph evaluation is correct
|
||||
"""
|
||||
self.do_visibility_object_add('EMPTY')
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
30
tests/python/view_layer/test_evaluation_visibility_h.py
Normal file
30
tests/python/view_layer/test_evaluation_visibility_h.py
Normal file
@@ -0,0 +1,30 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_visibility_cylinder(self):
|
||||
"""
|
||||
See if the depsgraph evaluation is correct
|
||||
"""
|
||||
self.do_visibility_object_add('CYLINDER')
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
30
tests/python/view_layer/test_evaluation_visibility_i.py
Normal file
30
tests/python/view_layer/test_evaluation_visibility_i.py
Normal file
@@ -0,0 +1,30 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_visibility_torus(self):
|
||||
"""
|
||||
See if the depsgraph evaluation is correct
|
||||
"""
|
||||
self.do_visibility_object_add('TORUS')
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
109
tests/python/view_layer/test_layer_linking.py
Normal file
109
tests/python/view_layer/test_layer_linking.py
Normal file
@@ -0,0 +1,109 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def do_layer_linking(self, filepath_json, link_mode):
|
||||
import bpy
|
||||
import os
|
||||
import tempfile
|
||||
import filecmp
|
||||
|
||||
ROOT = self.get_root()
|
||||
with tempfile.TemporaryDirectory() as dirpath:
|
||||
filepath_layers = os.path.join(ROOT, 'layers.blend')
|
||||
|
||||
# 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')
|
||||
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')
|
||||
|
||||
# test linking sync
|
||||
subzero.objects.link(three_b)
|
||||
scorpion.objects.link(three_c)
|
||||
|
||||
# test unlinking sync
|
||||
layer = scene.view_layers.new('Fresh new Layer')
|
||||
|
||||
if link_mode in {'COLLECTION_LINK', 'COLLECTION_UNLINK'}:
|
||||
layer.collections.link(subzero)
|
||||
|
||||
if link_mode == 'COLLECTION_UNLINK':
|
||||
initial_collection = layer.collections['Master Collection']
|
||||
layer.collections.unlink(initial_collection)
|
||||
|
||||
# save file
|
||||
filepath_nested = os.path.join(dirpath, 'nested.blend')
|
||||
bpy.ops.wm.save_mainfile('EXEC_DEFAULT', filepath=filepath_nested)
|
||||
|
||||
# get the generated json
|
||||
datas = query_scene(filepath_nested, 'Main', (get_scene_collections, get_layers))
|
||||
self.assertTrue(datas, "Data is not valid")
|
||||
|
||||
filepath_nested_json = os.path.join(dirpath, "nested.json")
|
||||
with open(filepath_nested_json, "w") as f:
|
||||
for data in datas:
|
||||
f.write(dump(data))
|
||||
|
||||
self.assertTrue(compare_files(
|
||||
filepath_nested_json,
|
||||
filepath_json,
|
||||
),
|
||||
"Scene dump files differ")
|
||||
|
||||
def test_syncing_layer_new(self):
|
||||
"""
|
||||
See if the creation of new layers is going well
|
||||
"""
|
||||
import os
|
||||
ROOT = self.get_root()
|
||||
filepath_json = os.path.join(ROOT, 'layers_new_layer.json')
|
||||
self.do_layer_linking(filepath_json, 'LAYER_NEW')
|
||||
|
||||
def test_syncing_layer_collection_link(self):
|
||||
"""
|
||||
See if the creation of new layers is going well
|
||||
And linking a new scene collection in the layer works
|
||||
"""
|
||||
import os
|
||||
ROOT = self.get_root()
|
||||
filepath_json = os.path.join(ROOT, 'layers_layer_collection_link.json')
|
||||
self.do_layer_linking(filepath_json, 'COLLECTION_LINK')
|
||||
|
||||
def test_syncing_layer_collection_unlink(self):
|
||||
"""
|
||||
See if the creation of new layers is going well
|
||||
And unlinking the origin scene collection works
|
||||
"""
|
||||
import os
|
||||
ROOT = self.get_root()
|
||||
filepath_json = os.path.join(ROOT, 'layers_layer_collection_unlink.json')
|
||||
self.do_layer_linking(filepath_json, 'COLLECTION_UNLINK')
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
113
tests/python/view_layer/test_layer_syncing.py
Normal file
113
tests/python/view_layer/test_layer_syncing.py
Normal file
@@ -0,0 +1,113 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def do_syncing(self, filepath_json, unlink_mode):
|
||||
import bpy
|
||||
import os
|
||||
import tempfile
|
||||
import filecmp
|
||||
|
||||
ROOT = self.get_root()
|
||||
with tempfile.TemporaryDirectory() as dirpath:
|
||||
filepath_layers = os.path.join(ROOT, 'layers.blend')
|
||||
|
||||
# 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')
|
||||
three_c = bpy.data.objects.get('T.3c')
|
||||
three_d = bpy.data.objects.get('T.3d')
|
||||
|
||||
scene = bpy.context.scene
|
||||
|
||||
subzero = scene.master_collection.collections['1'].collections.new('sub-zero')
|
||||
scorpion = scene.master_collection.collections['1'].collections.new('scorpion')
|
||||
|
||||
# test linking sync
|
||||
subzero.objects.link(three_b)
|
||||
scorpion.objects.link(three_c)
|
||||
|
||||
# test unlinking sync
|
||||
if unlink_mode in {'OBJECT', 'COLLECTION'}:
|
||||
scorpion.objects.link(three_d)
|
||||
scorpion.objects.unlink(three_d)
|
||||
|
||||
if unlink_mode == 'COLLECTION':
|
||||
scorpion.objects.link(three_d)
|
||||
scene.master_collection.collections['1'].collections.remove(subzero)
|
||||
scene.master_collection.collections['1'].collections.remove(scorpion)
|
||||
|
||||
# save file
|
||||
filepath_nested = os.path.join(dirpath, 'nested.blend')
|
||||
bpy.ops.wm.save_mainfile('EXEC_DEFAULT', filepath=filepath_nested)
|
||||
|
||||
# get the generated json
|
||||
datas = query_scene(filepath_nested, 'Main', (get_scene_collections, get_layers))
|
||||
self.assertTrue(datas, "Data is not valid")
|
||||
|
||||
filepath_nested_json = os.path.join(dirpath, "nested.json")
|
||||
with open(filepath_nested_json, "w") as f:
|
||||
for data in datas:
|
||||
f.write(dump(data))
|
||||
|
||||
self.assertTrue(compare_files(
|
||||
filepath_nested_json,
|
||||
filepath_json,
|
||||
),
|
||||
"Scene dump files differ")
|
||||
|
||||
def test_syncing_link(self):
|
||||
"""
|
||||
See if scene collections and layer collections are in sync
|
||||
when we create new subcollections and link new objects
|
||||
"""
|
||||
import os
|
||||
ROOT = self.get_root()
|
||||
filepath_json = os.path.join(ROOT, 'layers_nested.json')
|
||||
self.do_syncing(filepath_json, 'NONE')
|
||||
|
||||
def test_syncing_unlink_object(self):
|
||||
"""
|
||||
See if scene collections and layer collections are in sync
|
||||
when we create new subcollections, link new objects and unlink
|
||||
some.
|
||||
"""
|
||||
import os
|
||||
ROOT = self.get_root()
|
||||
filepath_json = os.path.join(ROOT, 'layers_nested.json')
|
||||
self.do_syncing(filepath_json, 'OBJECT')
|
||||
|
||||
def test_syncing_unlink_collection(self):
|
||||
"""
|
||||
See if scene collections and layer collections are in sync
|
||||
when we create new subcollections, link new objects and unlink full collections
|
||||
some.
|
||||
"""
|
||||
import os
|
||||
ROOT = self.get_root()
|
||||
filepath_json = os.path.join(ROOT, 'layers.json')
|
||||
self.do_syncing(filepath_json, 'COLLECTION')
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,48 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveLayerCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def get_reference_layers_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_layers_tree_map()
|
||||
|
||||
def test_layer_collection_move_a(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
self.assertFalse(self.move_below('Layer 1.3', 'Layer 1.C'))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_layer_collection_move_b(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
self.assertFalse(self.move_above('Layer 1.C', 'Layer 1.3'))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,48 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveLayerCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def get_reference_layers_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_layers_tree_map()
|
||||
|
||||
def test_layer_collection_move_a(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
self.assertFalse(self.move_below('Layer 1.3.cat', 'Layer 1.3.dog'))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_layer_collection_move_b(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
self.assertFalse(self.move_above('Layer 1.3.dog', 'Layer 1.3.cat'))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,48 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveLayerCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def get_reference_layers_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_layers_tree_map()
|
||||
|
||||
def test_layer_collection_move_a(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
self.assertFalse(self.move_below('Layer 1.3.cat', 'Layer 1.3.dog'))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_layer_collection_move_b(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
self.assertFalse(self.move_above('Layer 1.3.dog', 'Layer 1.3.cat'))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,48 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveLayerCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def get_reference_layers_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_layers_tree_map()
|
||||
|
||||
def test_layer_collection_move_a(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
self.assertFalse(self.move_above('Layer 2.3.dog', 'Layer 1.C.2'))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_layer_collection_move_b(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
self.assertFalse(self.move_below('Layer 1.C.2', 'Layer 2.3.dog'))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,40 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveLayerCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def get_reference_layers_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_layers_tree_map()
|
||||
|
||||
def test_layer_collection_move(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
self.assertFalse(self.move_below('Layer 1.Master Collection', 'Layer 1.C.1'))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,100 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveLayerCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
reference_tree_map = [
|
||||
['A', [
|
||||
['i', None],
|
||||
['ii', None],
|
||||
['iii', None],
|
||||
]],
|
||||
['B', None],
|
||||
['C', [
|
||||
['1', None],
|
||||
['3', [
|
||||
['dog', None],
|
||||
['cat', None],
|
||||
]],
|
||||
['2', None],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def get_reference_layers_tree_map(self):
|
||||
reference_layers_map = [
|
||||
['Layer 1', [
|
||||
'Master Collection',
|
||||
'C',
|
||||
'3',
|
||||
]],
|
||||
['Layer 2', [
|
||||
'C',
|
||||
'dog',
|
||||
'cat',
|
||||
]],
|
||||
]
|
||||
return reference_layers_map
|
||||
|
||||
def test_layer_collection_move_a(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
self.assertTrue(self.move_below('Layer 2.3', 'Layer 2.C.1'))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_layer_collection_move_b(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
self.assertTrue(self.move_above('Layer 2.3', 'Layer 2.C.2'))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_layer_collection_move_c(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
|
||||
# collection that will be moved
|
||||
collection_original = self.parse_move('Layer 2.3')
|
||||
collection_original.hide = False
|
||||
collection_original.hide_select = True
|
||||
|
||||
# collection that will disappear
|
||||
collection_old = self.parse_move('Layer 2.C.3')
|
||||
collection_old.hide = True
|
||||
collection_old.hide_select = False
|
||||
|
||||
# move
|
||||
self.assertTrue(self.move_below('Layer 2.3', 'Layer 2.C.1'))
|
||||
self.compare_tree_maps()
|
||||
|
||||
# we expect the settings to be carried along from the
|
||||
# original layer collection
|
||||
collection_new = self.parse_move('Layer 2.C.3')
|
||||
self.assertEqual(collection_new.hide, False)
|
||||
self.assertEqual(collection_new.hide_select, True)
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,81 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveLayerCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
reference_tree_map = [
|
||||
['A', [
|
||||
['i', None],
|
||||
['ii', None],
|
||||
['iii', None],
|
||||
]],
|
||||
['B', None],
|
||||
['C', [
|
||||
['1', None],
|
||||
['2', None],
|
||||
['3', [
|
||||
['cat', None],
|
||||
['dog', None],
|
||||
]],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def get_reference_layers_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_layers_tree_map()
|
||||
|
||||
def test_layer_collection_move_a(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
self.assertTrue(self.move_above('Layer 2.C.3.cat', 'Layer 2.3.dog'))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_layer_collection_move_b(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
|
||||
# collection that will be moved
|
||||
collection_original = self.parse_move('Layer 2.C.3.cat')
|
||||
collection_original.hide = False
|
||||
collection_original.hide_select = True
|
||||
|
||||
# collection that will disappear
|
||||
collection_old = self.parse_move('Layer 2.3.cat')
|
||||
collection_old.hide = True
|
||||
collection_old.hide_select = False
|
||||
|
||||
# move
|
||||
self.assertTrue(self.move_above('Layer 2.C.3.cat', 'Layer 2.3.dog'))
|
||||
self.compare_tree_maps()
|
||||
|
||||
# we expect the settings to be carried along from the
|
||||
# original layer collection
|
||||
collection_new = self.parse_move('Layer 2.3.cat')
|
||||
self.assertEqual(collection_new.hide, False)
|
||||
self.assertEqual(collection_new.hide_select, True)
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,66 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveLayerCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def get_reference_layers_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_layers_tree_map()
|
||||
|
||||
def test_layer_collection_move_a(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
self.assertTrue(self.move_below('Layer 2.C.3.cat', 'Layer 2.3.dog'))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_layer_collection_move_b(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
|
||||
# collection that will be moved
|
||||
collection_original = self.parse_move('Layer 2.C.3.cat')
|
||||
collection_original.hide = False
|
||||
collection_original.hide_select = True
|
||||
|
||||
# collection that will disappear
|
||||
collection_old = self.parse_move('Layer 2.3.cat')
|
||||
collection_old.hide = True
|
||||
collection_old.hide_select = False
|
||||
|
||||
# move
|
||||
self.assertTrue(self.move_below('Layer 2.C.3.cat', 'Layer 2.3.dog'))
|
||||
self.compare_tree_maps()
|
||||
|
||||
# we expect the settings to be carried along from the
|
||||
# original layer collection
|
||||
collection_new = self.parse_move('Layer 2.3.cat')
|
||||
self.assertEqual(collection_new.hide, False)
|
||||
self.assertEqual(collection_new.hide_select, True)
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,73 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveLayerCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def get_reference_layers_tree_map(self):
|
||||
reference_layers_map = [
|
||||
['Layer 1', [
|
||||
'Master Collection',
|
||||
'C',
|
||||
'3',
|
||||
]],
|
||||
['Layer 2', [
|
||||
'3',
|
||||
'C',
|
||||
'dog',
|
||||
'cat',
|
||||
]],
|
||||
]
|
||||
return reference_layers_map
|
||||
|
||||
def test_layer_collection_move_a(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
self.assertTrue(self.move_below('Layer 2.C', 'Layer 2.3'))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_layer_collection_move_b(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
|
||||
# collection that will be moved
|
||||
collection_original = self.parse_move('Layer 2.C')
|
||||
collection_original.hide = False
|
||||
collection_original.hide_select = True
|
||||
|
||||
# move
|
||||
self.assertTrue(self.move_below('Layer 2.C', 'Layer 2.3'))
|
||||
self.compare_tree_maps()
|
||||
|
||||
# we expect the settings to be carried along from the
|
||||
# original layer collection
|
||||
collection_new = self.parse_move('Layer 2.C')
|
||||
self.assertEqual(collection_new.hide, False)
|
||||
self.assertEqual(collection_new.hide_select, True)
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,63 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveLayerCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def get_reference_layers_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_layers_tree_map()
|
||||
|
||||
def test_layer_collection_move_a(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
self.assertTrue(self.move_below('Layer 1.3.dog', 'Layer 1.3.cat'))
|
||||
self.assertTrue(self.move_above('Layer 1.3.dog', 'Layer 1.3.cat'))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_layer_collection_move_b(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
|
||||
# collection that will be moved
|
||||
collection_original = self.parse_move('Layer 1.3.dog')
|
||||
collection_original.hide = False
|
||||
collection_original.hide_select = True
|
||||
|
||||
# move
|
||||
self.assertTrue(self.move_below('Layer 1.3.dog', 'Layer 1.3.cat'))
|
||||
self.assertTrue(self.move_above('Layer 1.3.dog', 'Layer 1.3.cat'))
|
||||
self.compare_tree_maps()
|
||||
|
||||
# we expect the settings to be carried along from the
|
||||
# original layer collection
|
||||
collection_new = self.parse_move('Layer 1.3.dog')
|
||||
self.assertEqual(collection_new.hide, False)
|
||||
self.assertEqual(collection_new.hide_select, True)
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,40 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveLayerCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def get_reference_layers_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_layers_tree_map()
|
||||
|
||||
def test_layer_collection_move(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
self.assertFalse(self.move_below('Layer 2.C.2', 'Layer 2.3'))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,60 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveLayerCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def get_reference_layers_tree_map(self):
|
||||
reference_layers_map = [
|
||||
['Layer 1', [
|
||||
'Master Collection',
|
||||
'C',
|
||||
'3',
|
||||
]],
|
||||
['Layer 2', [
|
||||
'C',
|
||||
'cat',
|
||||
'3',
|
||||
'dog',
|
||||
]],
|
||||
]
|
||||
return reference_layers_map
|
||||
|
||||
def test_layer_collection_move_a(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
self.assertTrue(self.move_below('Layer 2.cat', 'Layer 2.C'))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_layer_collection_move_b(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
self.assertTrue(self.move_above('Layer 2.cat', 'Layer 2.3'))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,80 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
reference_tree_map = [
|
||||
['A', [
|
||||
['i', None],
|
||||
['ii', None],
|
||||
['iii', None],
|
||||
]],
|
||||
['B', None],
|
||||
['C', [
|
||||
['1', None],
|
||||
['2', None],
|
||||
['3', [
|
||||
['dog', None],
|
||||
['cat', None],
|
||||
]],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def test_scene_collection_move_a(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['cat'].move_above(tree['dog']))
|
||||
self.assertTrue(tree['dog'].move_above(tree['cat']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_scene_collection_move_b(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['dog'].move_below(tree['cat']))
|
||||
self.assertTrue(tree['cat'].move_below(tree['dog']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_scene_collection_move_c(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['dog'].move_below(tree['cat']))
|
||||
self.assertTrue(tree['dog'].move_above(tree['cat']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_scene_collection_move_d(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['cat'].move_above(tree['dog']))
|
||||
self.assertTrue(tree['cat'].move_below(tree['dog']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,69 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
reference_tree_map = [
|
||||
['A', [
|
||||
['i', None],
|
||||
['ii', None],
|
||||
['iii', None],
|
||||
]],
|
||||
['B', None],
|
||||
['C', [
|
||||
['3', [
|
||||
['dog', None],
|
||||
['cat', None],
|
||||
]],
|
||||
['1', None],
|
||||
['2', None],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def test_scene_collection_move_a(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['3'].move_above(tree['1']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_scene_collection_move_b(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['1'].move_below(tree['3']))
|
||||
self.assertTrue(tree['2'].move_below(tree['1']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_scene_collection_move_c(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['3'].move_above(tree['2']))
|
||||
self.assertTrue(tree['1'].move_above(tree['2']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,51 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
reference_tree_map = [
|
||||
['A', [
|
||||
['i', None],
|
||||
['ii', None],
|
||||
['3', [
|
||||
['dog', None],
|
||||
['cat', None],
|
||||
]],
|
||||
['iii', None],
|
||||
]],
|
||||
['B', None],
|
||||
['C', [
|
||||
['1', None],
|
||||
['2', None],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def test_scene_collection_move(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['3'].move_below(tree['ii']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,60 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
reference_tree_map = [
|
||||
['A', [
|
||||
['i', None],
|
||||
['ii', None],
|
||||
['iii', None],
|
||||
]],
|
||||
['C', [
|
||||
['1', None],
|
||||
['2', None],
|
||||
['3', [
|
||||
['dog', None],
|
||||
['B', None],
|
||||
['cat', None],
|
||||
]],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def test_scene_collection_move_a(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['B'].move_above(tree['cat']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_scene_collection_move_b(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['B'].move_below(tree['dog']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,60 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
reference_tree_map = [
|
||||
['A', [
|
||||
['i', None],
|
||||
['ii', None],
|
||||
]],
|
||||
['B', None],
|
||||
['C', [
|
||||
['1', None],
|
||||
['2', None],
|
||||
['3', [
|
||||
['dog', None],
|
||||
['iii', None],
|
||||
['cat', None],
|
||||
]],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def test_scene_collection_move_a(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['iii'].move_below(tree['dog']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_scene_collection_move_b(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['iii'].move_above(tree['cat']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,51 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
reference_tree_map = [
|
||||
['B', None],
|
||||
['C', [
|
||||
['1', None],
|
||||
['2', None],
|
||||
['3', [
|
||||
['A', [
|
||||
['i', None],
|
||||
['ii', None],
|
||||
['iii', None],
|
||||
]],
|
||||
['dog', None],
|
||||
['cat', None],
|
||||
]],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def test_scene_collection_move(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['A'].move_above(tree['dog']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,44 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def test_scene_collection_move_a(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertFalse(tree['dog'].move_above(tree['cat']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_scene_collection_move_b(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertFalse(tree['cat'].move_below(tree['dog']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,84 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def test_scene_collection_move_a(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
import bpy
|
||||
master_collection = bpy.context.scene.master_collection
|
||||
|
||||
tree = self.setup_tree()
|
||||
for collection in tree.values():
|
||||
# can't move into master_collection anywhere
|
||||
self.assertFalse(master_collection.move_above(collection))
|
||||
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_scene_collection_move_b(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
import bpy
|
||||
master_collection = bpy.context.scene.master_collection
|
||||
|
||||
tree = self.setup_tree()
|
||||
for collection in tree.values():
|
||||
# can't move into master_collection anywhere
|
||||
self.assertFalse(master_collection.move_below(collection))
|
||||
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_scene_collection_move_c(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
import bpy
|
||||
master_collection = bpy.context.scene.master_collection
|
||||
|
||||
tree = self.setup_tree()
|
||||
for collection in tree.values():
|
||||
# can't move into master_collection anywhere
|
||||
self.assertFalse(collection.move_above(master_collection))
|
||||
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_scene_collection_move_d(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
import bpy
|
||||
master_collection = bpy.context.scene.master_collection
|
||||
|
||||
tree = self.setup_tree()
|
||||
for collection in tree.values():
|
||||
# can't move into master_collection anywhere
|
||||
self.assertFalse(collection.move_below(master_collection))
|
||||
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,60 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def test_scene_collection_move_a(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertFalse(tree['C'].move_above(tree['2']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_scene_collection_move_b(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertFalse(tree['C'].move_below(tree['2']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_scene_collection_move_c(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertFalse(tree['C'].move_above(tree['cat']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_scene_collection_move_d(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertFalse(tree['C'].move_below(tree['cat']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,80 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionSyncTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
reference_tree_map = [
|
||||
['A', [
|
||||
['i', None],
|
||||
['ii', None],
|
||||
['iii', None],
|
||||
]],
|
||||
['B', None],
|
||||
['C', [
|
||||
['1', None],
|
||||
['2', None],
|
||||
['3', [
|
||||
['dog', None],
|
||||
['cat', None],
|
||||
]],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def test_scene_collection_move_a(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['cat'].move_above(tree['dog']))
|
||||
self.assertTrue(tree['dog'].move_above(tree['cat']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_scene_collection_move_b(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['dog'].move_below(tree['cat']))
|
||||
self.assertTrue(tree['cat'].move_below(tree['dog']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_scene_collection_move_c(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['dog'].move_below(tree['cat']))
|
||||
self.assertTrue(tree['dog'].move_above(tree['cat']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_scene_collection_move_d(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['cat'].move_above(tree['dog']))
|
||||
self.assertTrue(tree['cat'].move_below(tree['dog']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,69 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionSyncTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
reference_tree_map = [
|
||||
['A', [
|
||||
['i', None],
|
||||
['ii', None],
|
||||
['iii', None],
|
||||
]],
|
||||
['B', None],
|
||||
['C', [
|
||||
['3', [
|
||||
['dog', None],
|
||||
['cat', None],
|
||||
]],
|
||||
['1', None],
|
||||
['2', None],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def test_scene_collection_move_a(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['3'].move_above(tree['1']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_scene_collection_move_b(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['1'].move_below(tree['3']))
|
||||
self.assertTrue(tree['2'].move_below(tree['1']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_scene_collection_move_c(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['3'].move_above(tree['2']))
|
||||
self.assertTrue(tree['1'].move_above(tree['2']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,51 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionSyncTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
reference_tree_map = [
|
||||
['A', [
|
||||
['i', None],
|
||||
['ii', None],
|
||||
['3', [
|
||||
['dog', None],
|
||||
['cat', None],
|
||||
]],
|
||||
['iii', None],
|
||||
]],
|
||||
['B', None],
|
||||
['C', [
|
||||
['1', None],
|
||||
['2', None],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def test_scene_collection_move(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['3'].move_below(tree['ii']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,60 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionSyncTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
reference_tree_map = [
|
||||
['A', [
|
||||
['i', None],
|
||||
['ii', None],
|
||||
['iii', None],
|
||||
]],
|
||||
['C', [
|
||||
['1', None],
|
||||
['2', None],
|
||||
['3', [
|
||||
['dog', None],
|
||||
['B', None],
|
||||
['cat', None],
|
||||
]],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def test_scene_collection_move_a(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['B'].move_above(tree['cat']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_scene_collection_move_b(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['B'].move_below(tree['dog']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,60 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionSyncTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
reference_tree_map = [
|
||||
['A', [
|
||||
['i', None],
|
||||
['ii', None],
|
||||
]],
|
||||
['B', None],
|
||||
['C', [
|
||||
['1', None],
|
||||
['2', None],
|
||||
['3', [
|
||||
['dog', None],
|
||||
['iii', None],
|
||||
['cat', None],
|
||||
]],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def test_scene_collection_move_a(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['iii'].move_below(tree['dog']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_scene_collection_move_b(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['iii'].move_above(tree['cat']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,51 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionSyncTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
reference_tree_map = [
|
||||
['B', None],
|
||||
['C', [
|
||||
['1', None],
|
||||
['2', None],
|
||||
['3', [
|
||||
['A', [
|
||||
['i', None],
|
||||
['ii', None],
|
||||
['iii', None],
|
||||
]],
|
||||
['dog', None],
|
||||
['cat', None],
|
||||
]],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def test_scene_collection_move(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['A'].move_above(tree['dog']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,44 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionSyncTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def test_scene_collection_move_a(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertFalse(tree['dog'].move_above(tree['cat']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_scene_collection_move_b(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertFalse(tree['cat'].move_below(tree['dog']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,84 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionSyncTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def test_scene_collection_move_a(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
import bpy
|
||||
master_collection = bpy.context.scene.master_collection
|
||||
|
||||
tree = self.setup_tree()
|
||||
for collection in tree.values():
|
||||
# can't move into master_collection anywhere
|
||||
self.assertFalse(master_collection.move_above(collection))
|
||||
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_scene_collection_move_b(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
import bpy
|
||||
master_collection = bpy.context.scene.master_collection
|
||||
|
||||
tree = self.setup_tree()
|
||||
for collection in tree.values():
|
||||
# can't move into master_collection anywhere
|
||||
self.assertFalse(master_collection.move_below(collection))
|
||||
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_scene_collection_move_c(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
import bpy
|
||||
master_collection = bpy.context.scene.master_collection
|
||||
|
||||
tree = self.setup_tree()
|
||||
for collection in tree.values():
|
||||
# can't move into master_collection anywhere
|
||||
self.assertFalse(collection.move_above(master_collection))
|
||||
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_scene_collection_move_d(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
import bpy
|
||||
master_collection = bpy.context.scene.master_collection
|
||||
|
||||
tree = self.setup_tree()
|
||||
for collection in tree.values():
|
||||
# can't move into master_collection anywhere
|
||||
self.assertFalse(collection.move_below(master_collection))
|
||||
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,60 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionSyncTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def test_scene_collection_move_a(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertFalse(tree['C'].move_above(tree['2']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_scene_collection_move_b(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertFalse(tree['C'].move_below(tree['2']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_scene_collection_move_c(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertFalse(tree['C'].move_above(tree['cat']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_scene_collection_move_d(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertFalse(tree['C'].move_below(tree['cat']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
69
tests/python/view_layer/test_move_into_layer_collection_a.py
Normal file
69
tests/python/view_layer/test_move_into_layer_collection_a.py
Normal file
@@ -0,0 +1,69 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveLayerCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
reference_tree_map = [
|
||||
['A', [
|
||||
['i', None],
|
||||
['ii', None],
|
||||
['iii', None],
|
||||
]],
|
||||
['B', None],
|
||||
['C', [
|
||||
['1', None],
|
||||
['2', None],
|
||||
['3', [
|
||||
['dog', None],
|
||||
['cat', None],
|
||||
]],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def get_reference_layers_tree_map(self):
|
||||
# original tree, no changes
|
||||
reference_layers_map = [
|
||||
['Layer 1', [
|
||||
'Master Collection',
|
||||
'C',
|
||||
'3',
|
||||
]],
|
||||
['Layer 2', [
|
||||
'C',
|
||||
'3',
|
||||
'dog',
|
||||
'cat',
|
||||
]],
|
||||
]
|
||||
return reference_layers_map
|
||||
|
||||
def test_layer_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
self.assertFalse(self.move_into("Layer 1.C.2", "Layer 2.3"))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
40
tests/python/view_layer/test_move_into_layer_collection_b.py
Normal file
40
tests/python/view_layer/test_move_into_layer_collection_b.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveLayerCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def get_reference_layers_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_layers_tree_map()
|
||||
|
||||
def test_layer_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
self.assertFalse(self.move_into('Layer 1.3', 'Layer 1.3.cat'))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
40
tests/python/view_layer/test_move_into_layer_collection_c.py
Normal file
40
tests/python/view_layer/test_move_into_layer_collection_c.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveLayerCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def get_reference_layers_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_layers_tree_map()
|
||||
|
||||
def test_layer_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
self.assertFalse(self.move_into("Layer 2.C", "Layer 2.3"))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
40
tests/python/view_layer/test_move_into_layer_collection_d.py
Normal file
40
tests/python/view_layer/test_move_into_layer_collection_d.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveLayerCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def get_reference_layers_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_layers_tree_map()
|
||||
|
||||
def test_layer_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
self.assertFalse(self.move_into("Layer 2.3.cat", "Layer 2.3"))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
40
tests/python/view_layer/test_move_into_layer_collection_e.py
Normal file
40
tests/python/view_layer/test_move_into_layer_collection_e.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveLayerCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def get_reference_layers_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_layers_tree_map()
|
||||
|
||||
def test_layer_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
self.assertFalse(self.move_into("Layer 1.Master Collection", "Layer 1.C"))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
86
tests/python/view_layer/test_move_into_layer_collection_f.py
Normal file
86
tests/python/view_layer/test_move_into_layer_collection_f.py
Normal file
@@ -0,0 +1,86 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveLayerCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
reference_tree_map = [
|
||||
['A', [
|
||||
['i', None],
|
||||
['ii', None],
|
||||
['iii', None],
|
||||
['3', [
|
||||
['dog', None],
|
||||
['cat', None],
|
||||
]],
|
||||
]],
|
||||
['B', None],
|
||||
['C', [
|
||||
['1', None],
|
||||
['2', None],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def get_reference_layers_tree_map(self):
|
||||
reference_layers_map = [
|
||||
['Layer 1', [
|
||||
'Master Collection',
|
||||
'C',
|
||||
]],
|
||||
['Layer 2', [
|
||||
'C',
|
||||
'3',
|
||||
'dog',
|
||||
'cat',
|
||||
]],
|
||||
]
|
||||
return reference_layers_map
|
||||
|
||||
def test_layer_collection_into_a(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
self.assertTrue(self.move_into("Layer 1.3", "Layer 1.Master Collection.A"))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_layer_collection_into_b(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
|
||||
# collection that will be moved
|
||||
collection_original = self.parse_move('Layer 1.3')
|
||||
collection_original.hide = False
|
||||
collection_original.hide_select = True
|
||||
|
||||
self.assertTrue(self.move_into('Layer 1.3', 'Layer 1.Master Collection.A'))
|
||||
self.compare_tree_maps()
|
||||
|
||||
# we expect the settings to be carried along from the
|
||||
# original layer collection
|
||||
collection_new = self.parse_move('Layer 1.Master Collection.A.3')
|
||||
self.assertEqual(collection_new.hide, False)
|
||||
self.assertEqual(collection_new.hide_select, True)
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
77
tests/python/view_layer/test_move_into_layer_collection_g.py
Normal file
77
tests/python/view_layer/test_move_into_layer_collection_g.py
Normal file
@@ -0,0 +1,77 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveLayerCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def get_reference_layers_tree_map(self):
|
||||
reference_layers_map = [
|
||||
['Layer 1', [
|
||||
'Master Collection',
|
||||
'C',
|
||||
'3',
|
||||
]],
|
||||
['Layer 2', [
|
||||
'C',
|
||||
'dog',
|
||||
'cat',
|
||||
]],
|
||||
]
|
||||
return reference_layers_map
|
||||
|
||||
def test_layer_collection_into_a(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
self.assertTrue(self.move_into('Layer 2.3', 'Layer 2.C'))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_layer_collection_into_b(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
|
||||
# collection that will be moved
|
||||
collection_original = self.parse_move('Layer 2.3')
|
||||
collection_original.hide = False
|
||||
collection_original.hide_select = True
|
||||
|
||||
# collection that will disappear
|
||||
collection_old = self.parse_move('Layer 2.C.3')
|
||||
collection_old.hide = True
|
||||
collection_old.hide_select = False
|
||||
|
||||
# move collection
|
||||
self.assertTrue(self.move_into('Layer 2.3', 'Layer 2.C'))
|
||||
self.compare_tree_maps()
|
||||
|
||||
# we expect the settings to be carried along from the
|
||||
# original layer collection
|
||||
collection_new = self.parse_move('Layer 2.C.3')
|
||||
self.assertEqual(collection_new.hide, False)
|
||||
self.assertEqual(collection_new.hide_select, True)
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
76
tests/python/view_layer/test_move_into_layer_collection_h.py
Normal file
76
tests/python/view_layer/test_move_into_layer_collection_h.py
Normal file
@@ -0,0 +1,76 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveLayerCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
reference_tree_map = [
|
||||
['A', [
|
||||
['i', None],
|
||||
['ii', None],
|
||||
['iii', None],
|
||||
]],
|
||||
['B', None],
|
||||
['C', [
|
||||
['1', [
|
||||
['dog', None],
|
||||
]],
|
||||
['2', None],
|
||||
['3', [
|
||||
['cat', None],
|
||||
]],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def get_reference_layers_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_layers_tree_map()
|
||||
|
||||
def test_layer_collection_into_a(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
self.assertTrue(self.move_into('Layer 1.3.dog', 'Layer 1.C.1'))
|
||||
self.compare_tree_maps()
|
||||
|
||||
def test_layer_collection_into_b(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
|
||||
# collection that will be moved
|
||||
collection_original = self.parse_move('Layer 1.3.dog')
|
||||
collection_original.hide = False
|
||||
collection_original.hide_select = True
|
||||
|
||||
self.assertTrue(self.move_into('Layer 1.3.dog', 'Layer 1.C.1'))
|
||||
self.compare_tree_maps()
|
||||
|
||||
# we expect the settings to be carried along from the
|
||||
# original layer collection
|
||||
collection_new = self.parse_move('Layer 1.C.1.dog')
|
||||
self.assertEqual(collection_new.hide, False)
|
||||
self.assertEqual(collection_new.hide_select, True)
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
40
tests/python/view_layer/test_move_into_layer_collection_i.py
Normal file
40
tests/python/view_layer/test_move_into_layer_collection_i.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveLayerCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def get_reference_layers_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_layers_tree_map()
|
||||
|
||||
def test_layer_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
self.setup_tree()
|
||||
self.assertFalse(self.move_into('Layer 2.C.3', 'Layer 2.dog'))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
41
tests/python/view_layer/test_move_into_layer_collection_j.py
Normal file
41
tests/python/view_layer/test_move_into_layer_collection_j.py
Normal file
@@ -0,0 +1,41 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveLayerCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def get_reference_layers_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_layers_tree_map()
|
||||
|
||||
def test_layer_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
Prevent collection from being dragged into itself
|
||||
"""
|
||||
self.setup_tree()
|
||||
self.assertFalse(self.move_into("Layer 2.dog", "Layer 2.3.dog"))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
53
tests/python/view_layer/test_move_into_scene_collection_a.py
Normal file
53
tests/python/view_layer/test_move_into_scene_collection_a.py
Normal file
@@ -0,0 +1,53 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
reference_tree_map = [
|
||||
['A', [
|
||||
['i', None],
|
||||
['ii', None],
|
||||
['iii', None],
|
||||
]],
|
||||
['B', None],
|
||||
['C', [
|
||||
['1', None],
|
||||
['2', None],
|
||||
['3', [
|
||||
['dog', None],
|
||||
['cat', None],
|
||||
]],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def test_scene_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['cat'].move_into(tree['2']))
|
||||
self.assertTrue(tree['cat'].move_into(tree['3']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
52
tests/python/view_layer/test_move_into_scene_collection_b.py
Normal file
52
tests/python/view_layer/test_move_into_scene_collection_b.py
Normal file
@@ -0,0 +1,52 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
reference_tree_map = [
|
||||
['A', [
|
||||
['i', None],
|
||||
['ii', None],
|
||||
['iii', None],
|
||||
]],
|
||||
['B', [
|
||||
['3', [
|
||||
['dog', None],
|
||||
['cat', None],
|
||||
]],
|
||||
]],
|
||||
['C', [
|
||||
['1', None],
|
||||
['2', None],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def test_scene_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['3'].move_into(tree['B']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
52
tests/python/view_layer/test_move_into_scene_collection_c.py
Normal file
52
tests/python/view_layer/test_move_into_scene_collection_c.py
Normal file
@@ -0,0 +1,52 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
reference_tree_map = [
|
||||
['A', [
|
||||
['i', None],
|
||||
['ii', None],
|
||||
['iii', None],
|
||||
]],
|
||||
['B', None],
|
||||
['C', [
|
||||
['1', None],
|
||||
['2', None],
|
||||
['3', [
|
||||
['dog', [
|
||||
['cat', None],
|
||||
]],
|
||||
]],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def test_scene_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['cat'].move_into(tree['dog']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
37
tests/python/view_layer/test_move_into_scene_collection_d.py
Normal file
37
tests/python/view_layer/test_move_into_scene_collection_d.py
Normal file
@@ -0,0 +1,37 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def test_scene_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
# can't move into a collection if already the last item of the collection
|
||||
self.assertFalse(tree['cat'].move_into(tree['3']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
52
tests/python/view_layer/test_move_into_scene_collection_e.py
Normal file
52
tests/python/view_layer/test_move_into_scene_collection_e.py
Normal file
@@ -0,0 +1,52 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
reference_tree_map = [
|
||||
['A', [
|
||||
['i', None],
|
||||
['ii', None],
|
||||
['iii', None],
|
||||
]],
|
||||
['C', [
|
||||
['1', None],
|
||||
['2', None],
|
||||
['3', [
|
||||
['dog', None],
|
||||
['cat', [
|
||||
['B', None],
|
||||
]],
|
||||
]],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def test_scene_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['B'].move_into(tree['cat']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
51
tests/python/view_layer/test_move_into_scene_collection_f.py
Normal file
51
tests/python/view_layer/test_move_into_scene_collection_f.py
Normal file
@@ -0,0 +1,51 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
reference_tree_map = [
|
||||
['A', [
|
||||
['i', None],
|
||||
['ii', None],
|
||||
['iii', None],
|
||||
]],
|
||||
['C', [
|
||||
['1', None],
|
||||
['2', None],
|
||||
['3', [
|
||||
['dog', None],
|
||||
['cat', None],
|
||||
['B', None],
|
||||
]],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def test_scene_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['B'].move_into(tree['3']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
52
tests/python/view_layer/test_move_into_scene_collection_g.py
Normal file
52
tests/python/view_layer/test_move_into_scene_collection_g.py
Normal file
@@ -0,0 +1,52 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
reference_tree_map = [
|
||||
['B', None],
|
||||
['C', [
|
||||
['1', None],
|
||||
['2', None],
|
||||
['3', [
|
||||
['dog', [
|
||||
['A', [
|
||||
['i', None],
|
||||
['ii', None],
|
||||
['iii', None],
|
||||
]],
|
||||
]],
|
||||
['cat', None],
|
||||
]],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def test_scene_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['A'].move_into(tree['dog']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
52
tests/python/view_layer/test_move_into_scene_collection_h.py
Normal file
52
tests/python/view_layer/test_move_into_scene_collection_h.py
Normal file
@@ -0,0 +1,52 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
reference_tree_map = [
|
||||
['A', [
|
||||
['i', None],
|
||||
['iii', None],
|
||||
]],
|
||||
['B', None],
|
||||
['C', [
|
||||
['1', None],
|
||||
['2', [
|
||||
['ii', None],
|
||||
]],
|
||||
['3', [
|
||||
['dog', None],
|
||||
['cat', None],
|
||||
]],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def test_scene_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['ii'].move_into(tree['2']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
52
tests/python/view_layer/test_move_into_scene_collection_i.py
Normal file
52
tests/python/view_layer/test_move_into_scene_collection_i.py
Normal file
@@ -0,0 +1,52 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
reference_tree_map = [
|
||||
['A', [
|
||||
['i', None],
|
||||
['iii', None],
|
||||
]],
|
||||
['B', None],
|
||||
['C', [
|
||||
['1', None],
|
||||
['2', None],
|
||||
['3', [
|
||||
['dog', [
|
||||
['ii', None],
|
||||
]],
|
||||
['cat', None],
|
||||
]],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def test_scene_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['ii'].move_into(tree['dog']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
43
tests/python/view_layer/test_move_into_scene_collection_j.py
Normal file
43
tests/python/view_layer/test_move_into_scene_collection_j.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def test_scene_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
import bpy
|
||||
master_collection = bpy.context.scene.master_collection
|
||||
|
||||
tree = self.setup_tree()
|
||||
|
||||
for collection in tree.values():
|
||||
# can't move into master_collection anywhere
|
||||
self.assertFalse(master_collection.move_into(collection))
|
||||
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
36
tests/python/view_layer/test_move_into_scene_collection_k.py
Normal file
36
tests/python/view_layer/test_move_into_scene_collection_k.py
Normal file
@@ -0,0 +1,36 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def test_scene_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertFalse(tree['C'].move_into(tree['2']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
36
tests/python/view_layer/test_move_into_scene_collection_l.py
Normal file
36
tests/python/view_layer/test_move_into_scene_collection_l.py
Normal file
@@ -0,0 +1,36 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def test_scene_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertFalse(tree['C'].move_into(tree['cat']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,37 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionSyncTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def test_scene_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['cat'].move_into(tree['2']))
|
||||
self.assertTrue(tree['cat'].move_into(tree['3']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,52 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionSyncTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
reference_tree_map = [
|
||||
['A', [
|
||||
['i', None],
|
||||
['ii', None],
|
||||
['iii', None],
|
||||
]],
|
||||
['B', [
|
||||
['3', [
|
||||
['dog', None],
|
||||
['cat', None],
|
||||
]],
|
||||
]],
|
||||
['C', [
|
||||
['1', None],
|
||||
['2', None],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def test_scene_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['3'].move_into(tree['B']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,52 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionSyncTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
reference_tree_map = [
|
||||
['A', [
|
||||
['i', None],
|
||||
['ii', None],
|
||||
['iii', None],
|
||||
]],
|
||||
['B', None],
|
||||
['C', [
|
||||
['1', None],
|
||||
['2', None],
|
||||
['3', [
|
||||
['dog', [
|
||||
['cat', None],
|
||||
]],
|
||||
]],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def test_scene_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['cat'].move_into(tree['dog']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,37 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionSyncTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def test_scene_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
# can't move into a collection if already the last item of the collection
|
||||
self.assertFalse(tree['cat'].move_into(tree['3']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,52 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionSyncTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
reference_tree_map = [
|
||||
['A', [
|
||||
['i', None],
|
||||
['ii', None],
|
||||
['iii', None],
|
||||
]],
|
||||
['C', [
|
||||
['1', None],
|
||||
['2', None],
|
||||
['3', [
|
||||
['dog', None],
|
||||
['cat', [
|
||||
['B', None],
|
||||
]],
|
||||
]],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def test_scene_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['B'].move_into(tree['cat']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,51 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionSyncTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
reference_tree_map = [
|
||||
['A', [
|
||||
['i', None],
|
||||
['ii', None],
|
||||
['iii', None],
|
||||
]],
|
||||
['C', [
|
||||
['1', None],
|
||||
['2', None],
|
||||
['3', [
|
||||
['dog', None],
|
||||
['cat', None],
|
||||
['B', None],
|
||||
]],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def test_scene_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['B'].move_into(tree['3']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,52 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionSyncTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
reference_tree_map = [
|
||||
['B', None],
|
||||
['C', [
|
||||
['1', None],
|
||||
['2', None],
|
||||
['3', [
|
||||
['dog', [
|
||||
['A', [
|
||||
['i', None],
|
||||
['ii', None],
|
||||
['iii', None],
|
||||
]],
|
||||
]],
|
||||
['cat', None],
|
||||
]],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def test_scene_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['A'].move_into(tree['dog']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,52 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionSyncTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
reference_tree_map = [
|
||||
['A', [
|
||||
['i', None],
|
||||
['iii', None],
|
||||
]],
|
||||
['B', None],
|
||||
['C', [
|
||||
['1', None],
|
||||
['2', [
|
||||
['ii', None],
|
||||
]],
|
||||
['3', [
|
||||
['dog', None],
|
||||
['cat', None],
|
||||
]],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def test_scene_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['ii'].move_into(tree['2']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,52 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionSyncTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
reference_tree_map = [
|
||||
['A', [
|
||||
['i', None],
|
||||
['iii', None],
|
||||
]],
|
||||
['B', None],
|
||||
['C', [
|
||||
['1', None],
|
||||
['2', None],
|
||||
['3', [
|
||||
['dog', [
|
||||
['ii', None],
|
||||
]],
|
||||
['cat', None],
|
||||
]],
|
||||
]],
|
||||
]
|
||||
return reference_tree_map
|
||||
|
||||
def test_scene_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertTrue(tree['ii'].move_into(tree['dog']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,43 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionSyncTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def test_scene_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
import bpy
|
||||
master_collection = bpy.context.scene.master_collection
|
||||
|
||||
tree = self.setup_tree()
|
||||
|
||||
for collection in tree.values():
|
||||
# can't move into master_collection anywhere
|
||||
self.assertFalse(master_collection.move_into(collection))
|
||||
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,36 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionSyncTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def test_scene_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertFalse(tree['C'].move_into(tree['2']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,36 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(MoveSceneCollectionSyncTesting):
|
||||
def get_reference_scene_tree_map(self):
|
||||
# original tree, no changes
|
||||
return self.get_initial_scene_tree_map()
|
||||
|
||||
def test_scene_collection_into(self):
|
||||
"""
|
||||
Test outliner operations
|
||||
"""
|
||||
tree = self.setup_tree()
|
||||
self.assertFalse(tree['C'].move_into(tree['cat']))
|
||||
self.compare_tree_maps()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
34
tests/python/view_layer/test_object_add_cylinder.py
Normal file
34
tests/python/view_layer/test_object_add_cylinder.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_syncing_object_add_cylinder(self):
|
||||
"""
|
||||
See if new objects are added to the correct collection
|
||||
bpy.ops.mesh.primitive_cylinder_add()
|
||||
"""
|
||||
import os
|
||||
ROOT = self.get_root()
|
||||
filepath_json = os.path.join(ROOT, 'layers_object_add_cylinder.json')
|
||||
self.do_object_add(filepath_json, 'CYLINDER')
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
34
tests/python/view_layer/test_object_add_empty.py
Normal file
34
tests/python/view_layer/test_object_add_empty.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_syncing_object_add_empty(self):
|
||||
"""
|
||||
See if new objects are added to the correct collection
|
||||
bpy.ops.object.add()
|
||||
"""
|
||||
import os
|
||||
ROOT = self.get_root()
|
||||
filepath_json = os.path.join(ROOT, 'layers_object_add_empty.json')
|
||||
self.do_object_add(filepath_json, 'EMPTY')
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,32 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_object_add_cylinder(self):
|
||||
"""
|
||||
See if new objects are added to the correct collection
|
||||
bpy.ops.mesh.primitive_cylinder_add()
|
||||
"""
|
||||
import os
|
||||
self.do_object_add_no_collection('CYLINDER')
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,31 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_syncing_object_add_empty(self):
|
||||
"""
|
||||
See if new objects are added to the correct collection
|
||||
bpy.ops.object.add()
|
||||
"""
|
||||
self.do_object_add_no_collection('EMPTY')
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
@@ -0,0 +1,31 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_syncing_object_add_torus(self):
|
||||
"""
|
||||
See if new objects are added to the correct collection
|
||||
bpy.ops.mesh.primitive_torus_add()
|
||||
"""
|
||||
self.do_object_add_no_collection('TORUS')
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
34
tests/python/view_layer/test_object_add_torus.py
Normal file
34
tests/python/view_layer/test_object_add_torus.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_syncing_object_add_torus(self):
|
||||
"""
|
||||
See if new objects are added to the correct collection
|
||||
bpy.ops.mesh.primitive_torus_add()
|
||||
"""
|
||||
import os
|
||||
ROOT = self.get_root()
|
||||
filepath_json = os.path.join(ROOT, 'layers_object_add_torus.json')
|
||||
self.do_object_add(filepath_json, 'TORUS')
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
94
tests/python/view_layer/test_object_copy.py
Normal file
94
tests/python/view_layer/test_object_copy.py
Normal file
@@ -0,0 +1,94 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def do_object_copy(self, mode):
|
||||
import bpy
|
||||
import os
|
||||
import tempfile
|
||||
import filecmp
|
||||
|
||||
ROOT = self.get_root()
|
||||
with tempfile.TemporaryDirectory() as dirpath:
|
||||
filepath_layers = os.path.join(ROOT, 'layers.blend')
|
||||
filepath_json = os.path.join(ROOT, 'layers_object_copy_duplicate.json')
|
||||
|
||||
# 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')
|
||||
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.view_layers.new('Fresh new Layer')
|
||||
layer.collections.link(subzero)
|
||||
|
||||
scene.view_layers.active_index = len(scene.view_layers) - 1
|
||||
bpy.context.workspace.view_layer = bpy.context.scene.view_layers['Fresh new Layer']
|
||||
|
||||
if mode == 'DUPLICATE':
|
||||
# assuming the latest layer is the active layer
|
||||
bpy.ops.object.select_all(action='DESELECT')
|
||||
three_c.select_set(action='SELECT')
|
||||
bpy.ops.object.duplicate()
|
||||
|
||||
elif mode == 'NAMED':
|
||||
bpy.ops.object.add_named(name=three_c.name)
|
||||
|
||||
# save file
|
||||
filepath_objects = os.path.join(dirpath, 'objects.blend')
|
||||
bpy.ops.wm.save_mainfile('EXEC_DEFAULT', filepath=filepath_objects)
|
||||
|
||||
# get the generated json
|
||||
datas = query_scene(filepath_objects, 'Main', (get_scene_collections, get_layers))
|
||||
self.assertTrue(datas, "Data is not valid")
|
||||
|
||||
filepath_objects_json = os.path.join(dirpath, "objects.json")
|
||||
with open(filepath_objects_json, "w") as f:
|
||||
for data in datas:
|
||||
f.write(dump(data))
|
||||
|
||||
self.assertTrue(compare_files(
|
||||
filepath_objects_json,
|
||||
filepath_json,
|
||||
),
|
||||
"Scene dump files differ")
|
||||
|
||||
def test_copy_object(self):
|
||||
"""
|
||||
OBJECT_OT_duplicate
|
||||
"""
|
||||
self.do_object_copy('DUPLICATE')
|
||||
|
||||
def test_copy_object_named(self):
|
||||
"""
|
||||
OBJECT_OT_add_named
|
||||
"""
|
||||
self.do_object_copy('NAMED')
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
31
tests/python/view_layer/test_object_delete_a.py
Normal file
31
tests/python/view_layer/test_object_delete_a.py
Normal file
@@ -0,0 +1,31 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_object_delete_data(self):
|
||||
"""
|
||||
See if objects are removed correctly from all related collections
|
||||
bpy.data.objects.remove()
|
||||
"""
|
||||
self.do_object_delete('DATA')
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
31
tests/python/view_layer/test_object_delete_b.py
Normal file
31
tests/python/view_layer/test_object_delete_b.py
Normal file
@@ -0,0 +1,31 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_object_delete_operator(self):
|
||||
"""
|
||||
See if new objects are added to the correct collection
|
||||
bpy.ops.object.del()
|
||||
"""
|
||||
self.do_object_delete('OPERATOR')
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
32
tests/python/view_layer/test_object_link_a.py
Normal file
32
tests/python/view_layer/test_object_link_a.py
Normal file
@@ -0,0 +1,32 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_object_link_scene(self):
|
||||
"""
|
||||
See if we can link objects
|
||||
"""
|
||||
import bpy
|
||||
master_collection = bpy.context.scene.master_collection
|
||||
self.do_object_link(master_collection)
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
34
tests/python/view_layer/test_object_link_b.py
Normal file
34
tests/python/view_layer/test_object_link_b.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_object_link_context(self):
|
||||
"""
|
||||
See if we can link objects via bpy.context.scene_collection
|
||||
"""
|
||||
import bpy
|
||||
bpy.context.scene.view_layers.active_index = len(bpy.context.scene.view_layers) - 1
|
||||
bpy.context.workspace.view_layer = bpy.context.scene.view_layers['Viewport']
|
||||
master_collection = bpy.context.scene_collection
|
||||
self.do_object_link(master_collection)
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
35
tests/python/view_layer/test_object_link_c.py
Normal file
35
tests/python/view_layer/test_object_link_c.py
Normal file
@@ -0,0 +1,35 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_object_link_reload(self):
|
||||
"""
|
||||
See if we can link objects and not crash
|
||||
"""
|
||||
import bpy
|
||||
master_collection = bpy.context.scene.master_collection
|
||||
self.do_object_link(master_collection)
|
||||
|
||||
# force depsgraph to update
|
||||
bpy.ops.wm.read_factory_settings()
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
130
tests/python/view_layer/test_operator_context.py
Normal file
130
tests/python/view_layer/test_operator_context.py
Normal file
@@ -0,0 +1,130 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_operator_context(self):
|
||||
"""
|
||||
See if view layer context is properly set/get with operators overrides
|
||||
when we set view_layer in context, the collection should change as well
|
||||
"""
|
||||
import bpy
|
||||
import os
|
||||
|
||||
class SampleOperator(bpy.types.Operator):
|
||||
bl_idname = "testing.sample"
|
||||
bl_label = "Sample Operator"
|
||||
|
||||
view_layer = bpy.props.StringProperty(
|
||||
default="Not Set",
|
||||
options={'SKIP_SAVE'},
|
||||
)
|
||||
|
||||
scene_collection = bpy.props.StringProperty(
|
||||
default="",
|
||||
options={'SKIP_SAVE'},
|
||||
)
|
||||
|
||||
use_verbose = bpy.props.BoolProperty(
|
||||
default=False,
|
||||
options={'SKIP_SAVE'},
|
||||
)
|
||||
|
||||
def execute(self, context):
|
||||
view_layer = context.view_layer
|
||||
ret = {'FINISHED'}
|
||||
|
||||
# this is simply playing safe
|
||||
if view_layer.name != self.view_layer:
|
||||
if self.use_verbose:
|
||||
print('ERROR: Render Layer mismatch: "{0}" != "{1}"'.format(
|
||||
view_layer.name, self.view_layer))
|
||||
ret = {'CANCELLED'}
|
||||
|
||||
scene_collection_name = None
|
||||
if self.scene_collection:
|
||||
scene_collection_name = self.scene_collection
|
||||
else:
|
||||
scene_collection_name = view_layer.collections.active.name
|
||||
|
||||
# while this is the real test
|
||||
if context.scene_collection.name != scene_collection_name:
|
||||
if self.use_verbose:
|
||||
print('ERROR: Scene Collection mismatch: "{0}" != "{1}"'.format(
|
||||
context.scene_collection.name, scene_collection_name))
|
||||
ret = {'CANCELLED'}
|
||||
return ret
|
||||
|
||||
bpy.utils.register_class(SampleOperator)
|
||||
|
||||
# open sample file
|
||||
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')
|
||||
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.view_layers.new('Fresh new Layer')
|
||||
layer.collections.unlink(layer.collections.active)
|
||||
layer.collections.link(subzero)
|
||||
layer.collections.active_index = 3
|
||||
self.assertEqual(layer.collections.active.name, 'scorpion')
|
||||
|
||||
# Change active scene layer (do it for workspace too just to don't get mangled in workspace bugs)
|
||||
scene = bpy.context.scene
|
||||
scene.view_layers.active_index = len(scene.view_layers) - 2
|
||||
self.assertEqual(scene.view_layers.active.name, "Viewport")
|
||||
bpy.context.workspace.view_layer = bpy.context.scene.view_layers['Viewport']
|
||||
|
||||
# old layer
|
||||
self.assertEqual(bpy.ops.testing.sample(view_layer='Viewport', use_verbose=True), {'FINISHED'})
|
||||
|
||||
# expected to fail
|
||||
self.assertTrue(bpy.ops.testing.sample(view_layer=layer.name), {'CANCELLED'})
|
||||
|
||||
# set view layer and scene collection
|
||||
override = bpy.context.copy()
|
||||
override["view_layer"] = layer
|
||||
override["scene_collection"] = subzero
|
||||
self.assertEqual(bpy.ops.testing.sample(
|
||||
override,
|
||||
view_layer=layer.name,
|
||||
scene_collection=subzero.name, # 'sub-zero'
|
||||
use_verbose=True), {'FINISHED'})
|
||||
|
||||
# set only view layer
|
||||
override = bpy.context.copy()
|
||||
override["view_layer"] = layer
|
||||
|
||||
self.assertEqual(bpy.ops.testing.sample(
|
||||
override,
|
||||
view_layer=layer.name,
|
||||
scene_collection=layer.collections.active.name, # 'scorpion'
|
||||
use_verbose=True), {'FINISHED'})
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
37
tests/python/view_layer/test_scene_copy_a.py
Normal file
37
tests/python/view_layer/test_scene_copy_a.py
Normal file
@@ -0,0 +1,37 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_scene_collections_copy_full(self):
|
||||
"""
|
||||
See if scene copying 'FULL_COPY' is working for scene collections
|
||||
"""
|
||||
import os
|
||||
ROOT = self.get_root()
|
||||
|
||||
filepath_layers_json_copy = os.path.join(ROOT, 'layers_copy_full_simple.json')
|
||||
self.do_scene_copy(
|
||||
filepath_layers_json_copy,
|
||||
'FULL_COPY',
|
||||
(get_scene_collections,))
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
38
tests/python/view_layer/test_scene_copy_b.py
Normal file
38
tests/python/view_layer/test_scene_copy_b.py
Normal file
@@ -0,0 +1,38 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_scene_collections_link(self):
|
||||
"""
|
||||
See if scene copying 'LINK_OBJECTS' is working for scene collections
|
||||
"""
|
||||
import os
|
||||
ROOT = self.get_root()
|
||||
|
||||
# note: nothing should change, so using `layers_simple.json`
|
||||
filepath_layers_json_copy = os.path.join(ROOT, 'layers_simple.json')
|
||||
self.do_scene_copy(
|
||||
filepath_layers_json_copy,
|
||||
'LINK_OBJECTS',
|
||||
(get_scene_collections,))
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
37
tests/python/view_layer/test_scene_copy_c.py
Normal file
37
tests/python/view_layer/test_scene_copy_c.py
Normal file
@@ -0,0 +1,37 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_scene_layers_copy(self):
|
||||
"""
|
||||
See if scene copying 'FULL_COPY' is working for scene layers
|
||||
"""
|
||||
import os
|
||||
ROOT = self.get_root()
|
||||
|
||||
filepath_layers_json_copy = os.path.join(ROOT, 'layers_copy_full.json')
|
||||
self.do_scene_copy(
|
||||
filepath_layers_json_copy,
|
||||
'FULL_COPY',
|
||||
(get_scene_collections, get_layers))
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
37
tests/python/view_layer/test_scene_copy_d.py
Normal file
37
tests/python/view_layer/test_scene_copy_d.py
Normal file
@@ -0,0 +1,37 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_scene_layers_link(self):
|
||||
"""
|
||||
See if scene copying 'LINK_OBJECTS' is working for scene layers
|
||||
"""
|
||||
import os
|
||||
ROOT = self.get_root()
|
||||
|
||||
filepath_layers_json_copy = os.path.join(ROOT, 'layers_copy_link.json')
|
||||
self.do_scene_copy(
|
||||
filepath_layers_json_copy,
|
||||
'LINK_OBJECTS',
|
||||
(get_scene_collections, get_layers))
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
47
tests/python/view_layer/test_scene_copy_e.py
Normal file
47
tests/python/view_layer/test_scene_copy_e.py
Normal file
@@ -0,0 +1,47 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_shared_layer_collections_copy_full(self):
|
||||
"""
|
||||
See if scene copying 'FULL_COPY' is working for scene collections
|
||||
with a shared object
|
||||
"""
|
||||
import os
|
||||
import bpy
|
||||
|
||||
scene = bpy.context.scene
|
||||
layer = bpy.context.view_layer
|
||||
|
||||
original_cube = layer.objects.get('Cube')
|
||||
original_cube.select_set('SELECT')
|
||||
self.assertTrue(original_cube.select_get())
|
||||
|
||||
bpy.ops.scene.new(type='FULL_COPY')
|
||||
new_layer = bpy.context.view_layer
|
||||
|
||||
self.assertNotEqual(layer, new_layer)
|
||||
new_cube = new_layer.objects.get('Cube.001')
|
||||
self.assertNotEqual(original_cube, new_cube)
|
||||
self.assertTrue(new_cube.select_get())
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
94
tests/python/view_layer/test_scene_copy_f.py
Normal file
94
tests/python/view_layer/test_scene_copy_f.py
Normal file
@@ -0,0 +1,94 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_shared_layer_collections_copy_full(self):
|
||||
"""
|
||||
See if scene copying 'FULL_COPY' is keeping collections visibility
|
||||
and selectability.
|
||||
"""
|
||||
import os
|
||||
import bpy
|
||||
|
||||
scene = bpy.context.scene
|
||||
|
||||
hide_lookup = [0, 1, 1, 0]
|
||||
hide_lookup_sub = [1, 0, 1]
|
||||
|
||||
hide_select_lookup = [0, 0, 1, 1]
|
||||
hide_select_lookup_sub = [1, 0, 1, 0]
|
||||
new_collections = []
|
||||
|
||||
# clean everything
|
||||
for layer in scene.view_layers:
|
||||
while layer.collections:
|
||||
layer.collections.unlink(layer.collections[0])
|
||||
|
||||
# create new collections
|
||||
for i in range(4):
|
||||
collection = scene.master_collection.collections.new(str(i))
|
||||
new_collections.append(collection)
|
||||
|
||||
for j in range(3):
|
||||
sub_collection = collection.collections.new("{0}:{1}".format(i, j))
|
||||
|
||||
# link to the original scene
|
||||
for layer in scene.view_layers:
|
||||
for i, collection in enumerate(new_collections):
|
||||
layer.collections.link(collection)
|
||||
self.assertEqual(layer.collections[-1], layer.collections[i])
|
||||
|
||||
layer.collections[i].hide = hide_lookup[i]
|
||||
layer.collections[i].hide_select = hide_select_lookup[i]
|
||||
|
||||
for j, sub_collection in enumerate(layer.collections[i].collections):
|
||||
sub_collection.hide = hide_lookup_sub[j]
|
||||
sub_collection.hide_select = hide_select_lookup_sub[j]
|
||||
|
||||
# copy scene
|
||||
bpy.ops.scene.new(type='FULL_COPY')
|
||||
new_scene = bpy.context.scene
|
||||
self.assertNotEqual(scene, new_scene)
|
||||
|
||||
# update depsgrah
|
||||
scene.update() # update depsgraph
|
||||
|
||||
# compare scenes
|
||||
for h, layer in enumerate(scene.view_layers):
|
||||
new_layer = new_scene.view_layers[h]
|
||||
|
||||
for i, collection in enumerate(layer.collections):
|
||||
new_collection = new_layer.collections[i]
|
||||
self.assertEqual(collection.hide, new_collection.hide)
|
||||
self.assertEqual(collection.hide_select, new_collection.hide_select)
|
||||
|
||||
for j, sub_collection in enumerate(layer.collections[i].collections):
|
||||
new_sub_collection = new_collection.collections[j]
|
||||
self.assertEqual(sub_collection.hide, new_sub_collection.hide)
|
||||
self.assertEqual(sub_collection.hide_select, new_sub_collection.hide_select)
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
|
||||
extra_arguments = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
|
||||
sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 2:] if "--" in sys.argv else [])
|
||||
|
||||
UnitTesting._extra_arguments = extra_arguments
|
||||
unittest.main()
|
||||
39
tests/python/view_layer/test_scene_delete.py
Normal file
39
tests/python/view_layer/test_scene_delete.py
Normal file
@@ -0,0 +1,39 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def test_scene_delete(self):
|
||||
"""
|
||||
See if a scene can be properly deleted
|
||||
"""
|
||||
import bpy
|
||||
|
||||
scene = bpy.context.scene
|
||||
bpy.data.scenes.new('New')
|
||||
bpy.data.scenes.remove(scene)
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
|
||||
extra_arguments = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
|
||||
sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 2:] if "--" in sys.argv else [])
|
||||
|
||||
UnitTesting._extra_arguments = extra_arguments
|
||||
unittest.main()
|
||||
144
tests/python/view_layer/test_scene_write_read.py
Normal file
144
tests/python/view_layer/test_scene_write_read.py
Normal file
@@ -0,0 +1,144 @@
|
||||
# ############################################################
|
||||
# Importing - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from view_layer_common import *
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Testing
|
||||
# ############################################################
|
||||
|
||||
class UnitTesting(ViewLayerTesting):
|
||||
def do_scene_write_read(self, filepath_layers, filepath_layers_json, data_callbacks, do_read):
|
||||
"""
|
||||
See if write/read is working for scene collections and layers
|
||||
"""
|
||||
import bpy
|
||||
import os
|
||||
import tempfile
|
||||
import filecmp
|
||||
|
||||
with tempfile.TemporaryDirectory() as dirpath:
|
||||
(self.path_exists(f) for f in (filepath_layers, filepath_layers_json))
|
||||
|
||||
filepath_doversion = os.path.join(dirpath, 'doversion.blend')
|
||||
filepath_saved = os.path.join(dirpath, 'doversion_saved.blend')
|
||||
filepath_read_json = os.path.join(dirpath, "read.json")
|
||||
|
||||
# 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)
|
||||
self.assertTrue(datas, "Data is not valid")
|
||||
|
||||
filepath_doversion_json = os.path.join(dirpath, "doversion.json")
|
||||
with open(filepath_doversion_json, "w") as f:
|
||||
for data in datas:
|
||||
f.write(dump(data))
|
||||
|
||||
self.assertTrue(compare_files(
|
||||
filepath_doversion_json,
|
||||
filepath_layers_json,
|
||||
),
|
||||
"Run: test_scene_write_layers")
|
||||
|
||||
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)
|
||||
self.assertTrue(datas, "Data is not valid")
|
||||
|
||||
with open(filepath_read_json, "w") as f:
|
||||
for data in datas:
|
||||
f.write(dump(data))
|
||||
|
||||
self.assertTrue(compare_files(
|
||||
filepath_read_json,
|
||||
filepath_layers_json,
|
||||
),
|
||||
"Scene dump files differ")
|
||||
|
||||
def test_scene_write_collections(self):
|
||||
"""
|
||||
See if the doversion and writing are working for scene collections
|
||||
"""
|
||||
import os
|
||||
|
||||
ROOT = self.get_root()
|
||||
filepath_layers = os.path.join(ROOT, 'layers.blend')
|
||||
filepath_layers_json = os.path.join(ROOT, 'layers_simple.json')
|
||||
|
||||
self.do_scene_write_read(
|
||||
filepath_layers,
|
||||
filepath_layers_json,
|
||||
(get_scene_collections,),
|
||||
False)
|
||||
|
||||
def test_scene_write_layers(self):
|
||||
"""
|
||||
See if the doversion and writing are working for collections and layers
|
||||
"""
|
||||
import os
|
||||
|
||||
ROOT = self.get_root()
|
||||
filepath_layers = os.path.join(ROOT, 'layers.blend')
|
||||
filepath_layers_json = os.path.join(ROOT, 'layers.json')
|
||||
|
||||
self.do_scene_write_read(
|
||||
filepath_layers,
|
||||
filepath_layers_json,
|
||||
(get_scene_collections, get_layers),
|
||||
False)
|
||||
|
||||
def test_scene_read_collections(self):
|
||||
"""
|
||||
See if read is working for scene collections
|
||||
(run `test_scene_write_colections` first)
|
||||
"""
|
||||
import os
|
||||
|
||||
ROOT = self.get_root()
|
||||
filepath_layers = os.path.join(ROOT, 'layers.blend')
|
||||
filepath_layers_json = os.path.join(ROOT, 'layers_simple.json')
|
||||
|
||||
self.do_scene_write_read(
|
||||
filepath_layers,
|
||||
filepath_layers_json,
|
||||
(get_scene_collections,),
|
||||
True)
|
||||
|
||||
def test_scene_read_layers(self):
|
||||
"""
|
||||
See if read is working for scene layers
|
||||
(run `test_scene_write_layers` first)
|
||||
"""
|
||||
import os
|
||||
|
||||
ROOT = self.get_root()
|
||||
filepath_layers = os.path.join(ROOT, 'layers.blend')
|
||||
filepath_layers_json = os.path.join(ROOT, 'layers.json')
|
||||
|
||||
self.do_scene_write_read(
|
||||
filepath_layers,
|
||||
filepath_layers_json,
|
||||
(get_scene_collections, get_layers),
|
||||
True)
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Main - Same For All Render Layer Tests
|
||||
# ############################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
UnitTesting._extra_arguments = setup_extra_arguments(__file__)
|
||||
unittest.main()
|
||||
810
tests/python/view_layer/view_layer_common.py
Normal file
810
tests/python/view_layer/view_layer_common.py
Normal file
@@ -0,0 +1,810 @@
|
||||
import unittest
|
||||
|
||||
# ############################################################
|
||||
# Layer Collection Crawler
|
||||
# ############################################################
|
||||
|
||||
|
||||
def listbase_iter(data, struct, listbase):
|
||||
element = data.get_pointer((struct, listbase, b'first'))
|
||||
while element is not None:
|
||||
yield element
|
||||
element = element.get_pointer(b'next')
|
||||
|
||||
|
||||
def linkdata_iter(collection, data):
|
||||
element = collection.get_pointer((data, b'first'))
|
||||
while element is not None:
|
||||
yield element
|
||||
element = element.get_pointer(b'next')
|
||||
|
||||
|
||||
def get_layer_collection(layer_collection):
|
||||
data = {}
|
||||
flag = layer_collection.get(b'flag')
|
||||
|
||||
data['is_visible'] = (flag & (1 << 0)) != 0
|
||||
data['is_selectable'] = (flag & (1 << 1)) != 0
|
||||
data['is_disabled'] = (flag & (1 << 2)) != 0
|
||||
|
||||
scene_collection = layer_collection.get_pointer(b'scene_collection')
|
||||
if scene_collection is None:
|
||||
name = 'Fail!'
|
||||
else:
|
||||
name = scene_collection.get(b'name')
|
||||
data['name'] = name
|
||||
|
||||
objects = []
|
||||
for link in linkdata_iter(layer_collection, b'object_bases'):
|
||||
ob_base = link.get_pointer(b'data')
|
||||
ob = ob_base.get_pointer(b'object')
|
||||
objects.append(ob.get((b'id', b'name'))[2:])
|
||||
data['objects'] = objects
|
||||
|
||||
collections = {}
|
||||
for nested_layer_collection in linkdata_iter(layer_collection, b'layer_collections'):
|
||||
subname, subdata = get_layer_collection(nested_layer_collection)
|
||||
collections[subname] = subdata
|
||||
data['collections'] = collections
|
||||
|
||||
return name, data
|
||||
|
||||
|
||||
def get_layer(scene, layer):
|
||||
data = {}
|
||||
name = layer.get(b'name')
|
||||
|
||||
data['name'] = name
|
||||
data['engine'] = scene.get((b'view_render', b'engine_id'))
|
||||
|
||||
active_base = layer.get_pointer(b'basact')
|
||||
if active_base:
|
||||
ob = active_base.get_pointer(b'object')
|
||||
data['active_object'] = ob.get((b'id', b'name'))[2:]
|
||||
else:
|
||||
data['active_object'] = ""
|
||||
|
||||
objects = []
|
||||
for link in linkdata_iter(layer, b'object_bases'):
|
||||
ob = link.get_pointer(b'object')
|
||||
objects.append(ob.get((b'id', b'name'))[2:])
|
||||
data['objects'] = objects
|
||||
|
||||
collections = {}
|
||||
for layer_collection in linkdata_iter(layer, b'layer_collections'):
|
||||
subname, subdata = get_layer_collection(layer_collection)
|
||||
collections[subname] = subdata
|
||||
data['collections'] = collections
|
||||
|
||||
return name, data
|
||||
|
||||
|
||||
def get_layers(scene):
|
||||
"""Return all the render layers and their data"""
|
||||
layers = {}
|
||||
for layer in linkdata_iter(scene, b'view_layers'):
|
||||
name, data = get_layer(scene, layer)
|
||||
layers[name] = data
|
||||
return layers
|
||||
|
||||
|
||||
def get_scene_collection_objects(collection, listbase):
|
||||
objects = []
|
||||
for link in linkdata_iter(collection, listbase):
|
||||
ob = link.get_pointer(b'data')
|
||||
if ob is None:
|
||||
name = 'Fail!'
|
||||
else:
|
||||
name = ob.get((b'id', b'name'))[2:]
|
||||
objects.append(name)
|
||||
return objects
|
||||
|
||||
|
||||
def get_scene_collection(collection):
|
||||
""""""
|
||||
data = {}
|
||||
name = collection.get(b'name')
|
||||
|
||||
data['name'] = name
|
||||
data['filter'] = collection.get(b'filter')
|
||||
|
||||
data['objects'] = get_scene_collection_objects(collection, b'objects')
|
||||
data['filter_objects'] = get_scene_collection_objects(collection, b'filter_objects')
|
||||
|
||||
collections = {}
|
||||
for nested_collection in linkdata_iter(collection, b'scene_collections'):
|
||||
subname, subdata = get_scene_collection(nested_collection)
|
||||
collections[subname] = subdata
|
||||
data['collections'] = collections
|
||||
|
||||
return name, data
|
||||
|
||||
|
||||
def get_scene_collections(scene):
|
||||
"""Return all the scene collections ahd their data"""
|
||||
master_collection = scene.get_pointer(b'collection')
|
||||
return get_scene_collection(master_collection)
|
||||
|
||||
|
||||
def query_scene(filepath, name, callbacks):
|
||||
"""Return the equivalent to bpy.context.scene"""
|
||||
from io_blend_utils.blend import blendfile
|
||||
|
||||
with blendfile.open_blend(filepath) as blend:
|
||||
scenes = [block for block in blend.blocks if block.code == b'SC']
|
||||
for scene in scenes:
|
||||
if scene.get((b'id', b'name'))[2:] != name:
|
||||
continue
|
||||
|
||||
return [callback(scene) for callback in callbacks]
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Utils
|
||||
# ############################################################
|
||||
|
||||
def dump(data):
|
||||
import json
|
||||
return json.dumps(
|
||||
data,
|
||||
sort_keys=True,
|
||||
indent=4,
|
||||
separators=(',', ': '),
|
||||
)
|
||||
|
||||
|
||||
# ############################################################
|
||||
# Tests
|
||||
# ############################################################
|
||||
|
||||
PDB = False
|
||||
DUMP_DIFF = True
|
||||
UPDATE_DIFF = False # HACK used to update tests when something change
|
||||
|
||||
|
||||
def compare_files(file_a, file_b):
|
||||
import filecmp
|
||||
|
||||
if not filecmp.cmp(
|
||||
file_a,
|
||||
file_b):
|
||||
|
||||
if DUMP_DIFF:
|
||||
import subprocess
|
||||
subprocess.call(["diff", "-u", file_a, file_b])
|
||||
|
||||
if UPDATE_DIFF:
|
||||
import subprocess
|
||||
subprocess.call(["cp", "-u", file_a, file_b])
|
||||
|
||||
|
||||
if PDB:
|
||||
import pdb
|
||||
print("Files differ:", file_a, file_b)
|
||||
pdb.set_trace()
|
||||
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
class ViewLayerTesting(unittest.TestCase):
|
||||
_test_simple = False
|
||||
_extra_arguments = []
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
"""Runs once"""
|
||||
cls.pretest_parsing()
|
||||
|
||||
@classmethod
|
||||
def get_root(cls):
|
||||
"""
|
||||
return the folder with the test files
|
||||
"""
|
||||
arguments = {}
|
||||
for argument in cls._extra_arguments:
|
||||
name, value = argument.split('=')
|
||||
cls.assertTrue(name and name.startswith("--"), "Invalid argument \"{0}\"".format(argument))
|
||||
cls.assertTrue(value, "Invalid argument \"{0}\"".format(argument))
|
||||
arguments[name[2:]] = value.strip('"')
|
||||
|
||||
return arguments.get('testdir')
|
||||
|
||||
@classmethod
|
||||
def pretest_parsing(cls):
|
||||
"""
|
||||
Test if the arguments are properly set, and store ROOT
|
||||
name has extra _ because we need this test to run first
|
||||
"""
|
||||
root = cls.get_root()
|
||||
cls.assertTrue(root, "Testdir not set")
|
||||
|
||||
def setUp(self):
|
||||
"""Runs once per test"""
|
||||
import bpy
|
||||
bpy.ops.wm.read_factory_settings()
|
||||
|
||||
def path_exists(self, filepath):
|
||||
import os
|
||||
self.assertTrue(
|
||||
os.path.exists(filepath),
|
||||
"Test file \"{0}\" not found".format(filepath))
|
||||
|
||||
def do_object_add(self, filepath_json, add_mode):
|
||||
"""
|
||||
Testing for adding objects and see if they
|
||||
go to the right collection
|
||||
"""
|
||||
import bpy
|
||||
import os
|
||||
import tempfile
|
||||
import filecmp
|
||||
|
||||
ROOT = self.get_root()
|
||||
with tempfile.TemporaryDirectory() as dirpath:
|
||||
filepath_layers = os.path.join(ROOT, 'layers.blend')
|
||||
|
||||
# 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')
|
||||
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.view_layers.new('Fresh new Layer')
|
||||
layer.collections.link(subzero)
|
||||
|
||||
# change active collection
|
||||
layer.collections.active_index = 3
|
||||
self.assertEqual(layer.collections.active.name, 'scorpion', "Run: test_syncing_object_add")
|
||||
|
||||
# change active layer
|
||||
override = bpy.context.copy()
|
||||
override["view_layer"] = layer
|
||||
override["scene_collection"] = layer.collections.active.collection
|
||||
|
||||
# add new objects
|
||||
if add_mode == 'EMPTY':
|
||||
bpy.ops.object.add(override) # 'Empty'
|
||||
|
||||
elif add_mode == 'CYLINDER':
|
||||
bpy.ops.mesh.primitive_cylinder_add(override) # 'Cylinder'
|
||||
|
||||
elif add_mode == 'TORUS':
|
||||
bpy.ops.mesh.primitive_torus_add(override) # 'Torus'
|
||||
|
||||
# save file
|
||||
filepath_objects = os.path.join(dirpath, 'objects.blend')
|
||||
bpy.ops.wm.save_mainfile('EXEC_DEFAULT', filepath=filepath_objects)
|
||||
|
||||
# get the generated json
|
||||
datas = query_scene(filepath_objects, 'Main', (get_scene_collections, get_layers))
|
||||
self.assertTrue(datas, "Data is not valid")
|
||||
|
||||
filepath_objects_json = os.path.join(dirpath, "objects.json")
|
||||
with open(filepath_objects_json, "w") as f:
|
||||
for data in datas:
|
||||
f.write(dump(data))
|
||||
|
||||
self.assertTrue(compare_files(
|
||||
filepath_objects_json,
|
||||
filepath_json,
|
||||
),
|
||||
"Scene dump files differ")
|
||||
|
||||
def do_object_add_no_collection(self, add_mode):
|
||||
"""
|
||||
Test for adding objects when no collection
|
||||
exists in render layer
|
||||
"""
|
||||
import bpy
|
||||
|
||||
# empty layer of collections
|
||||
|
||||
layer = bpy.context.view_layer
|
||||
while layer.collections:
|
||||
layer.collections.unlink(layer.collections[0])
|
||||
|
||||
# add new objects
|
||||
if add_mode == 'EMPTY':
|
||||
bpy.ops.object.add() # 'Empty'
|
||||
|
||||
elif add_mode == 'CYLINDER':
|
||||
bpy.ops.mesh.primitive_cylinder_add() # 'Cylinder'
|
||||
|
||||
elif add_mode == 'TORUS':
|
||||
bpy.ops.mesh.primitive_torus_add() # 'Torus'
|
||||
|
||||
self.assertEqual(len(layer.collections), 1, "New collection not created")
|
||||
collection = layer.collections[0]
|
||||
self.assertEqual(len(collection.objects), 1, "New collection is empty")
|
||||
|
||||
def do_object_link(self, master_collection):
|
||||
import bpy
|
||||
self.assertEqual(master_collection.name, "Master Collection")
|
||||
self.assertEqual(master_collection, bpy.context.scene.master_collection)
|
||||
master_collection.objects.link(bpy.data.objects.new('object', None))
|
||||
|
||||
def do_scene_copy(self, filepath_json_reference, copy_mode, data_callbacks):
|
||||
import bpy
|
||||
import os
|
||||
import tempfile
|
||||
import filecmp
|
||||
|
||||
ROOT = self.get_root()
|
||||
with tempfile.TemporaryDirectory() as dirpath:
|
||||
filepath_layers = os.path.join(ROOT, 'layers.blend')
|
||||
|
||||
(self.path_exists(f) for f in (
|
||||
filepath_layers,
|
||||
filepath_json_reference,
|
||||
))
|
||||
|
||||
filepath_saved = os.path.join(dirpath, '{0}.blend'.format(copy_mode))
|
||||
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)
|
||||
|
||||
datas = query_scene(filepath_saved, 'Main.001', data_callbacks)
|
||||
self.assertTrue(datas, "Data is not valid")
|
||||
|
||||
with open(filepath_json, "w") as f:
|
||||
for data in datas:
|
||||
f.write(dump(data))
|
||||
|
||||
self.assertTrue(compare_files(
|
||||
filepath_json,
|
||||
filepath_json_reference,
|
||||
),
|
||||
"Scene copy \"{0}\" test failed".format(copy_mode.title()))
|
||||
|
||||
def do_object_delete(self, del_mode):
|
||||
import bpy
|
||||
import os
|
||||
import tempfile
|
||||
import filecmp
|
||||
|
||||
ROOT = self.get_root()
|
||||
with tempfile.TemporaryDirectory() as dirpath:
|
||||
filepath_layers = os.path.join(ROOT, 'layers.blend')
|
||||
filepath_reference_json = os.path.join(ROOT, 'layers_object_delete.json')
|
||||
|
||||
# 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')
|
||||
three_d = bpy.data.objects.get('T.3d')
|
||||
|
||||
scene = bpy.context.scene
|
||||
|
||||
# mangle the file a bit with some objects linked across collections
|
||||
subzero = scene.master_collection.collections['1'].collections.new('sub-zero')
|
||||
scorpion = subzero.collections.new('scorpion')
|
||||
subzero.objects.link(three_d)
|
||||
scorpion.objects.link(three_b)
|
||||
scorpion.objects.link(three_d)
|
||||
|
||||
# object to delete
|
||||
ob = three_d
|
||||
|
||||
# delete object
|
||||
if del_mode == 'DATA':
|
||||
bpy.data.objects.remove(ob, do_unlink=True)
|
||||
|
||||
elif del_mode == 'OPERATOR':
|
||||
bpy.context.scene.update() # update depsgraph
|
||||
bpy.ops.object.select_all(action='DESELECT')
|
||||
ob.select_set(action='SELECT')
|
||||
self.assertTrue(ob.select_get())
|
||||
bpy.ops.object.delete()
|
||||
|
||||
# save file
|
||||
filepath_generated = os.path.join(dirpath, 'generated.blend')
|
||||
bpy.ops.wm.save_mainfile('EXEC_DEFAULT', filepath=filepath_generated)
|
||||
|
||||
# get the generated json
|
||||
datas = query_scene(filepath_generated, 'Main', (get_scene_collections, get_layers))
|
||||
self.assertTrue(datas, "Data is not valid")
|
||||
|
||||
filepath_generated_json = os.path.join(dirpath, "generated.json")
|
||||
with open(filepath_generated_json, "w") as f:
|
||||
for data in datas:
|
||||
f.write(dump(data))
|
||||
|
||||
self.assertTrue(compare_files(
|
||||
filepath_generated_json,
|
||||
filepath_reference_json,
|
||||
),
|
||||
"Scene dump files differ")
|
||||
|
||||
def do_visibility_object_add(self, add_mode):
|
||||
import bpy
|
||||
|
||||
scene = bpy.context.scene
|
||||
|
||||
# delete all objects of the file
|
||||
for ob in bpy.data.objects:
|
||||
bpy.data.objects.remove(ob, do_unlink=True)
|
||||
|
||||
# real test
|
||||
layer = scene.view_layers.new('Visibility Test')
|
||||
layer.collections.unlink(layer.collections[0])
|
||||
scene.view_layers.active = layer
|
||||
|
||||
scene_collection = scene.master_collection.collections.new("Collection")
|
||||
layer.collections.link(scene_collection)
|
||||
|
||||
bpy.context.scene.update() # update depsgraph
|
||||
|
||||
self.assertEqual(len(bpy.data.objects), 0)
|
||||
|
||||
# add new objects
|
||||
if add_mode == 'EMPTY':
|
||||
bpy.ops.object.add() # 'Empty'
|
||||
|
||||
elif add_mode == 'CYLINDER':
|
||||
bpy.ops.mesh.primitive_cylinder_add() # 'Cylinder'
|
||||
|
||||
elif add_mode == 'TORUS':
|
||||
bpy.ops.mesh.primitive_torus_add() # 'Torus'
|
||||
|
||||
self.assertEqual(len(bpy.data.objects), 1)
|
||||
|
||||
new_ob = bpy.data.objects[0]
|
||||
self.assertTrue(new_ob.visible_get(), "Object should be visible")
|
||||
|
||||
def cleanup_tree(self):
|
||||
"""
|
||||
Remove any existent layer and collections,
|
||||
leaving only the one view_layer we can't remove
|
||||
"""
|
||||
import bpy
|
||||
scene = bpy.context.scene
|
||||
while len(scene.view_layers) > 1:
|
||||
scene.view_layers.remove(scene.view_layers[1])
|
||||
|
||||
layer = scene.view_layers[0]
|
||||
while layer.collections:
|
||||
layer.collections.unlink(layer.collections[0])
|
||||
|
||||
master_collection = scene.master_collection
|
||||
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(ViewLayerTesting):
|
||||
"""
|
||||
To be used by tests of view_layer_move_into_scene_collection
|
||||
"""
|
||||
def get_initial_scene_tree_map(self):
|
||||
collections_map = [
|
||||
['A', [
|
||||
['i', None],
|
||||
['ii', None],
|
||||
['iii', None],
|
||||
]],
|
||||
['B', None],
|
||||
['C', [
|
||||
['1', None],
|
||||
['2', None],
|
||||
['3', [
|
||||
['dog', None],
|
||||
['cat', None],
|
||||
]],
|
||||
]],
|
||||
]
|
||||
return collections_map
|
||||
|
||||
def build_scene_tree(self, tree_map, collection=None, ret_dict=None):
|
||||
"""
|
||||
Returns a flat dictionary with new scene collections
|
||||
created from a nested tuple of nested tuples (name, tuple)
|
||||
"""
|
||||
import bpy
|
||||
|
||||
if collection is None:
|
||||
collection = bpy.context.scene.master_collection
|
||||
|
||||
if ret_dict is None:
|
||||
ret_dict = {collection.name: collection}
|
||||
self.assertEqual(collection.name, "Master Collection")
|
||||
|
||||
for name, nested_collections in tree_map:
|
||||
new_collection = collection.collections.new(name)
|
||||
ret_dict[name] = new_collection
|
||||
|
||||
if nested_collections:
|
||||
self.build_scene_tree(nested_collections, new_collection, ret_dict)
|
||||
|
||||
return ret_dict
|
||||
|
||||
def setup_tree(self):
|
||||
"""
|
||||
Cleanup file, and populate it with class scene tree map
|
||||
"""
|
||||
self.cleanup_tree()
|
||||
self.assertTrue(
|
||||
hasattr(self, "get_initial_scene_tree_map"),
|
||||
"Test class has no get_initial_scene_tree_map method implemented")
|
||||
|
||||
return self.build_scene_tree(self.get_initial_scene_tree_map())
|
||||
|
||||
def get_scene_tree_map(self, collection=None, ret_list=None):
|
||||
"""
|
||||
Extract the scene collection tree from scene
|
||||
Return as a nested list of nested lists (name, list)
|
||||
"""
|
||||
import bpy
|
||||
|
||||
if collection is None:
|
||||
scene = bpy.context.scene
|
||||
collection = scene.master_collection
|
||||
|
||||
if ret_list is None:
|
||||
ret_list = []
|
||||
|
||||
for nested_collection in collection.collections:
|
||||
new_collection = [nested_collection.name, None]
|
||||
ret_list.append(new_collection)
|
||||
|
||||
if nested_collection.collections:
|
||||
new_collection[1] = list()
|
||||
self.get_scene_tree_map(nested_collection, new_collection[1])
|
||||
|
||||
return ret_list
|
||||
|
||||
def compare_tree_maps(self):
|
||||
"""
|
||||
Compare scene with expected (class defined) data
|
||||
"""
|
||||
self.assertEqual(self.get_scene_tree_map(), self.get_reference_scene_tree_map())
|
||||
|
||||
|
||||
class MoveSceneCollectionSyncTesting(MoveSceneCollectionTesting):
|
||||
"""
|
||||
To be used by tests of view_layer_move_into_scene_collection_sync
|
||||
"""
|
||||
def get_initial_layers_tree_map(self):
|
||||
layers_map = [
|
||||
['Layer 1', [
|
||||
'Master Collection',
|
||||
'C',
|
||||
'3',
|
||||
]],
|
||||
['Layer 2', [
|
||||
'C',
|
||||
'3',
|
||||
'dog',
|
||||
'cat',
|
||||
]],
|
||||
]
|
||||
return layers_map
|
||||
|
||||
def get_reference_layers_tree_map(self):
|
||||
"""
|
||||
For those classes we don't expect any changes in the layer tree
|
||||
"""
|
||||
return self.get_initial_layers_tree_map()
|
||||
|
||||
def setup_tree(self):
|
||||
tree = super(MoveSceneCollectionSyncTesting, self).setup_tree()
|
||||
|
||||
import bpy
|
||||
scene = bpy.context.scene
|
||||
|
||||
self.assertTrue(
|
||||
hasattr(self, "get_initial_layers_tree_map"),
|
||||
"Test class has no get_initial_layers_tree_map method implemented")
|
||||
|
||||
layers_map = self.get_initial_layers_tree_map()
|
||||
|
||||
for layer_name, collections_names in layers_map:
|
||||
layer = scene.view_layers.new(layer_name)
|
||||
layer.collections.unlink(layer.collections[0])
|
||||
|
||||
for collection_name in collections_names:
|
||||
layer.collections.link(tree[collection_name])
|
||||
|
||||
return tree
|
||||
|
||||
def compare_tree_maps(self):
|
||||
"""
|
||||
Compare scene with expected (class defined) data
|
||||
"""
|
||||
super(MoveSceneCollectionSyncTesting, self).compare_tree_maps()
|
||||
|
||||
import bpy
|
||||
scene = bpy.context.scene
|
||||
layers_map = self.get_reference_layers_tree_map()
|
||||
|
||||
for layer_name, collections_names in layers_map:
|
||||
layer = scene.view_layers.get(layer_name)
|
||||
self.assertTrue(layer)
|
||||
self.assertEqual(len(collections_names), len(layer.collections))
|
||||
|
||||
for i, collection_name in enumerate(collections_names):
|
||||
self.assertEqual(collection_name, layer.collections[i].name)
|
||||
self.verify_collection_tree(layer.collections[i])
|
||||
|
||||
def verify_collection_tree(self, layer_collection):
|
||||
"""
|
||||
Check if the LayerCollection mimics the SceneLayer tree
|
||||
"""
|
||||
scene_collection = layer_collection.collection
|
||||
self.assertEqual(len(layer_collection.collections), len(scene_collection.collections))
|
||||
|
||||
for i, nested_collection in enumerate(layer_collection.collections):
|
||||
self.assertEqual(nested_collection.collection.name, scene_collection.collections[i].name)
|
||||
self.assertEqual(nested_collection.collection, scene_collection.collections[i])
|
||||
self.verify_collection_tree(nested_collection)
|
||||
|
||||
|
||||
class MoveLayerCollectionTesting(MoveSceneCollectionSyncTesting):
|
||||
"""
|
||||
To be used by tests of view_layer_move_into_layer_collection
|
||||
"""
|
||||
def parse_move(self, path, sep='.'):
|
||||
"""
|
||||
convert 'Layer 1.C.2' into:
|
||||
bpy.context.scene.view_layers['Layer 1'].collections['C'].collections['2']
|
||||
"""
|
||||
import bpy
|
||||
|
||||
paths = path.split(sep)
|
||||
layer = bpy.context.scene.view_layers[paths[0]]
|
||||
collections = layer.collections
|
||||
|
||||
for subpath in paths[1:]:
|
||||
collection = collections[subpath]
|
||||
collections = collection.collections
|
||||
|
||||
return collection
|
||||
|
||||
def move_into(self, src, dst):
|
||||
layer_collection_src = self.parse_move(src)
|
||||
layer_collection_dst = self.parse_move(dst)
|
||||
return layer_collection_src.move_into(layer_collection_dst)
|
||||
|
||||
def move_above(self, src, dst):
|
||||
layer_collection_src = self.parse_move(src)
|
||||
layer_collection_dst = self.parse_move(dst)
|
||||
return layer_collection_src.move_above(layer_collection_dst)
|
||||
|
||||
def move_below(self, src, dst):
|
||||
layer_collection_src = self.parse_move(src)
|
||||
layer_collection_dst = self.parse_move(dst)
|
||||
return layer_collection_src.move_below(layer_collection_dst)
|
||||
|
||||
|
||||
class Clay:
|
||||
def __init__(self, extra_kid_layer=False):
|
||||
import bpy
|
||||
|
||||
self._scene = bpy.context.scene
|
||||
self._layer = self._fresh_layer()
|
||||
self._object = bpy.data.objects.new('guinea pig', bpy.data.meshes.new('mesh'))
|
||||
|
||||
# update depsgraph
|
||||
self._scene.update()
|
||||
|
||||
scene_collection_grandma = self._scene.master_collection.collections.new("Grandma")
|
||||
scene_collection_mom = scene_collection_grandma.collections.new("Mom")
|
||||
scene_collection_kid = scene_collection_mom.collections.new("Kid")
|
||||
scene_collection_kid.objects.link(self._object)
|
||||
|
||||
layer_collection_grandma = self._layer.collections.link(scene_collection_grandma)
|
||||
layer_collection_mom = layer_collection_grandma.collections[0]
|
||||
layer_collection_kid = layer_collection_mom.collections[0]
|
||||
|
||||
# store the variables
|
||||
self._scene_collections = {
|
||||
'grandma': scene_collection_grandma,
|
||||
'mom': scene_collection_mom,
|
||||
'kid': scene_collection_kid,
|
||||
}
|
||||
self._layer_collections = {
|
||||
'grandma': layer_collection_grandma,
|
||||
'mom': layer_collection_mom,
|
||||
'kid': layer_collection_kid,
|
||||
}
|
||||
|
||||
if extra_kid_layer:
|
||||
layer_collection_extra = self._layer.collections.link(scene_collection_kid)
|
||||
self._layer_collections['extra'] = layer_collection_extra
|
||||
|
||||
self._update()
|
||||
|
||||
def _fresh_layer(self):
|
||||
import bpy
|
||||
|
||||
# remove all other objects
|
||||
while bpy.data.objects:
|
||||
bpy.data.objects.remove(bpy.data.objects[0])
|
||||
|
||||
# remove all the other collections
|
||||
while self._scene.master_collection.collections:
|
||||
self._scene.master_collection.collections.remove(
|
||||
self._scene.master_collection.collections[0])
|
||||
|
||||
layer = self._scene.view_layers.new('Evaluation Test')
|
||||
layer.collections.unlink(layer.collections[0])
|
||||
self._scene.view_layers.active = layer
|
||||
bpy.context.workspace.view_layer = layer
|
||||
|
||||
# remove all other layers
|
||||
for layer_iter in self._scene.view_layers:
|
||||
if layer_iter != layer:
|
||||
self._scene.view_layers.remove(layer_iter)
|
||||
|
||||
return layer
|
||||
|
||||
def _update(self):
|
||||
"""
|
||||
Force depsgrpah evaluation
|
||||
and update pointers to IDProperty collections
|
||||
"""
|
||||
ENGINE = 'BLENDER_CLAY'
|
||||
|
||||
self._scene.update() # update depsgraph
|
||||
self._layer.update() # flush depsgraph evaluation
|
||||
|
||||
# change scene settings
|
||||
self._properties = {
|
||||
'scene': self._scene.collection_properties[ENGINE],
|
||||
'object': self._object.collection_properties[ENGINE],
|
||||
}
|
||||
|
||||
for key, value in self._layer_collections.items():
|
||||
self._properties[key] = self._layer_collections[key].engine_overrides[ENGINE]
|
||||
|
||||
def get(self, name, data_path):
|
||||
self._update()
|
||||
return getattr(self._properties[name], data_path)
|
||||
|
||||
def set(self, name, data_path, value):
|
||||
self._update()
|
||||
self._properties[name].use(data_path)
|
||||
setattr(self._properties[name], data_path, value)
|
||||
|
||||
|
||||
def setup_extra_arguments(filepath):
|
||||
"""
|
||||
Create a value which is assigned to: ``UnitTesting._extra_arguments``
|
||||
"""
|
||||
import sys
|
||||
|
||||
extra_arguments = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
|
||||
sys.argv = [filepath] + extra_arguments[1:]
|
||||
|
||||
return extra_arguments
|
||||
Reference in New Issue
Block a user