test_collection_rename_a.py 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 setup_family(self):
  13. import bpy
  14. scene = bpy.context.scene
  15. # Just add a bunch of collections on which we can do various tests.
  16. grandma = scene.master_collection.collections.new('grandma')
  17. grandpa = scene.master_collection.collections.new('grandpa')
  18. mom = grandma.collections.new('mom')
  19. son = mom.collections.new('son')
  20. daughter = mom.collections.new('daughter')
  21. uncle = grandma.collections.new('uncle')
  22. cousin = uncle.collections.new('cousin')
  23. lookup = {c.name: c for c in (grandma, grandpa, mom, son, daughter, uncle, cousin)}
  24. return lookup
  25. def test_rename_a(self):
  26. family = self.setup_family()
  27. family['mom'].name = family['daughter'].name
  28. # Since they are not siblings, we allow them to have the same name.
  29. self.assertEqual(family['mom'].name, family['daughter'].name)
  30. def test_rename_b(self):
  31. family = self.setup_family()
  32. family['grandma'].name = family['grandpa'].name
  33. self.assertNotEqual(family['grandma'].name, family['grandpa'].name)
  34. def test_rename_c(self):
  35. family = self.setup_family()
  36. family['cousin'].name = family['daughter'].name
  37. # Since they are not siblings, we allow them to have the same name.
  38. self.assertEqual(family['cousin'].name, family['daughter'].name)
  39. def test_rename_d(self):
  40. family = self.setup_family()
  41. family['son'].name = family['daughter'].name
  42. self.assertNotEqual(family['son'].name, family['daughter'].name)
  43. def test_rename_e(self):
  44. family = self.setup_family()
  45. family['grandma'].name = family['grandpa'].name
  46. self.assertNotEqual(family['grandma'].name, family['grandpa'].name)
  47. def test_add_equal_name_a(self):
  48. family = self.setup_family()
  49. other_daughter = family['mom'].collections.new(family['daughter'].name)
  50. self.assertNotEqual(other_daughter.name, family['daughter'].name)
  51. def test_add_equal_name_b(self):
  52. family = self.setup_family()
  53. other_aunt = family['grandma'].collections.new(family['daughter'].name)
  54. # Since they are not siblings, we allow them to have the same name.
  55. self.assertEqual(other_aunt.name, family['daughter'].name)
  56. def test_add_equal_name_c(self):
  57. family = self.setup_family()
  58. other_aunt = family['grandma'].collections.new(family['mom'].name)
  59. self.assertNotEqual(other_aunt.name, family['mom'].name)
  60. # ############################################################
  61. # Main - Same For All Render Layer Tests
  62. # ############################################################
  63. if __name__ == '__main__':
  64. UnitTesting._extra_arguments = setup_extra_arguments(__file__)
  65. unittest.main()