test_group_b.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # ############################################################
  2. # Importing - Same For All Render Layer Tests
  3. # ############################################################
  4. import unittest
  5. import os
  6. import sys
  7. from view_layer_common import *
  8. # ############################################################
  9. # Testing
  10. # ############################################################
  11. class UnitTesting(ViewLayerTesting):
  12. def test_group_create_basic(self):
  13. """
  14. See if the creation of new groups is preserving visibility flags
  15. from the original collections.
  16. """
  17. import bpy
  18. scene = bpy.context.scene
  19. # clean slate
  20. self.cleanup_tree()
  21. master_collection = scene.master_collection
  22. grandma = master_collection.collections.new('бабушка')
  23. mom = grandma.collections.new('матушка')
  24. child = bpy.data.objects.new("Child", None)
  25. mom.objects.link(child)
  26. grandma_layer_collection = scene.view_layers[0].collections.link(grandma)
  27. mom_layer_collection = grandma_layer_collection.collections[0]
  28. grandma_layer_collection.enabled = True
  29. grandma_layer_collection.enabled = True
  30. mom_layer_collection.enabled = False
  31. mom_layer_collection.selectable = True
  32. # update depsgraph
  33. bpy.context.view_layer.update()
  34. # create group
  35. group = grandma_layer_collection.create_group()
  36. # update depsgraph
  37. bpy.context.view_layer.update()
  38. # compare
  39. self.assertEqual(len(group.view_layer.collections), 1)
  40. grandma_group_layer = group.view_layer.collections[0]
  41. self.assertTrue(grandma_group_layer.enabled, True)
  42. self.assertTrue(grandma_group_layer.selectable)
  43. self.assertEqual(len(grandma_group_layer.collections), 1)
  44. mom_group_layer = grandma_group_layer.collections[0]
  45. self.assertFalse(mom_group_layer.enabled)
  46. self.assertTrue(mom_group_layer.selectable)
  47. # ############################################################
  48. # Main - Same For All Render Layer Tests
  49. # ############################################################
  50. if __name__ == '__main__':
  51. UnitTesting._extra_arguments = setup_extra_arguments(__file__)
  52. unittest.main()