diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2017-03-31 18:26:33 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2017-03-31 18:37:52 +0300 |
commit | b0998df60842f59d194163042a13cf4e0fde29d8 (patch) | |
tree | ac289a6aec54a84069279be1b41670d414649957 /tests | |
parent | d9b89ca0d0c8ad87e59994ad2c8a546614f75bdb (diff) |
Layers: Fix scene copying after IDProperty changes
(also unittest: split scene copy in 4 tests)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/python/render_layer/CMakeLists.txt | 5 | ||||
-rw-r--r-- | tests/python/render_layer/render_layer_common.py | 36 | ||||
-rw-r--r-- | tests/python/render_layer/test_scene_copy.py | 119 | ||||
-rw-r--r-- | tests/python/render_layer/test_scene_copy_a.py | 43 | ||||
-rw-r--r-- | tests/python/render_layer/test_scene_copy_b.py | 44 | ||||
-rw-r--r-- | tests/python/render_layer/test_scene_copy_c.py | 43 | ||||
-rw-r--r-- | tests/python/render_layer/test_scene_copy_d.py | 43 |
7 files changed, 213 insertions, 120 deletions
diff --git a/tests/python/render_layer/CMakeLists.txt b/tests/python/render_layer/CMakeLists.txt index f03a04a7029..d97672bd2c8 100644 --- a/tests/python/render_layer/CMakeLists.txt +++ b/tests/python/render_layer/CMakeLists.txt @@ -138,5 +138,8 @@ RENDER_LAYER_TEST(move_into_layer_collection_i) RENDER_LAYER_TEST(move_into_layer_collection_j) RENDER_LAYER_TEST(layer_linking) RENDER_LAYER_TEST(layer_syncinc) -RENDER_LAYER_TEST(scene_copy) +RENDER_LAYER_TEST(scene_copy_a) +RENDER_LAYER_TEST(scene_copy_b) +RENDER_LAYER_TEST(scene_copy_c) +RENDER_LAYER_TEST(scene_copy_d) RENDER_LAYER_TEST(scene_write_read) diff --git a/tests/python/render_layer/render_layer_common.py b/tests/python/render_layer/render_layer_common.py index faaefd6b8ed..5d4389482bb 100644 --- a/tests/python/render_layer/render_layer_common.py +++ b/tests/python/render_layer/render_layer_common.py @@ -346,6 +346,42 @@ class RenderLayerTesting(unittest.TestCase): 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 cleanup_tree(self): """ Remove any existent layer and collections, diff --git a/tests/python/render_layer/test_scene_copy.py b/tests/python/render_layer/test_scene_copy.py deleted file mode 100644 index 0b7665f6b28..00000000000 --- a/tests/python/render_layer/test_scene_copy.py +++ /dev/null @@ -1,119 +0,0 @@ -# ############################################################ -# Importing - Same For All Render Layer Tests -# ############################################################ - -import unittest -import os -import sys - -sys.path.append(os.path.dirname(__file__)) -from render_layer_common import * - - -# ############################################################ -# Testing -# ############################################################ - -class UnitTesting(RenderLayerTesting): - 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 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,)) - - 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,)) - - 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)) - - def test_scene_layers_link(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_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__': - 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() diff --git a/tests/python/render_layer/test_scene_copy_a.py b/tests/python/render_layer/test_scene_copy_a.py new file mode 100644 index 00000000000..b8973e9c4b3 --- /dev/null +++ b/tests/python/render_layer/test_scene_copy_a.py @@ -0,0 +1,43 @@ +# ############################################################ +# Importing - Same For All Render Layer Tests +# ############################################################ + +import unittest +import os +import sys + +sys.path.append(os.path.dirname(__file__)) +from render_layer_common import * + + +# ############################################################ +# Testing +# ############################################################ + +class UnitTesting(RenderLayerTesting): + 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__': + 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() diff --git a/tests/python/render_layer/test_scene_copy_b.py b/tests/python/render_layer/test_scene_copy_b.py new file mode 100644 index 00000000000..1d6aae7679b --- /dev/null +++ b/tests/python/render_layer/test_scene_copy_b.py @@ -0,0 +1,44 @@ +# ############################################################ +# Importing - Same For All Render Layer Tests +# ############################################################ + +import unittest +import os +import sys + +sys.path.append(os.path.dirname(__file__)) +from render_layer_common import * + + +# ############################################################ +# Testing +# ############################################################ + +class UnitTesting(RenderLayerTesting): + 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__': + 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() diff --git a/tests/python/render_layer/test_scene_copy_c.py b/tests/python/render_layer/test_scene_copy_c.py new file mode 100644 index 00000000000..7d8fb2560ec --- /dev/null +++ b/tests/python/render_layer/test_scene_copy_c.py @@ -0,0 +1,43 @@ +# ############################################################ +# Importing - Same For All Render Layer Tests +# ############################################################ + +import unittest +import os +import sys + +sys.path.append(os.path.dirname(__file__)) +from render_layer_common import * + + +# ############################################################ +# Testing +# ############################################################ + +class UnitTesting(RenderLayerTesting): + 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__': + 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() diff --git a/tests/python/render_layer/test_scene_copy_d.py b/tests/python/render_layer/test_scene_copy_d.py new file mode 100644 index 00000000000..9b75e57acaa --- /dev/null +++ b/tests/python/render_layer/test_scene_copy_d.py @@ -0,0 +1,43 @@ +# ############################################################ +# Importing - Same For All Render Layer Tests +# ############################################################ + +import unittest +import os +import sys + +sys.path.append(os.path.dirname(__file__)) +from render_layer_common import * + + +# ############################################################ +# Testing +# ############################################################ + +class UnitTesting(RenderLayerTesting): + def test_scene_layers_link(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_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__': + 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() |