Skip to content

Commit

Permalink
EMSUSD-134 unit test for parent to selection
Browse files Browse the repository at this point in the history
Verify that the parent command with a single argument wil parent to the selection. Only works in future Maya versions.
  • Loading branch information
pierrebai-adsk committed Jan 16, 2024
1 parent aa3193d commit edd8354
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions test/lib/ufe/testParentCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,51 @@ def checkParentDone():

checkParentDone()

@unittest.skipUnless(mayaUtils.mayaMajorVersion() > 2025, 'Requires Maya fixes only available in Maya greater than 2025.')
def testParentToSelection(self):
'''
Test that the parent command with a single argument will parent to the selection.
'''
# Create scene items for the cube and the cylinder.
shapeSegment = mayaUtils.createUfePathSegment(
"|mayaUsdProxy1|mayaUsdProxyShape1")

cylinderPath = ufe.Path(
[shapeSegment, usdUtils.createUfePathSegment("/cylinderXform")])
cylinderItem = ufe.Hierarchy.createItem(cylinderPath)

def verifyInitialSetup():
'''Verify that the cube is not a child of the cylinder.'''
cylHier = ufe.Hierarchy.hierarchy(cylinderItem)
cylChildren = cylHier.children()
self.assertEqual(len(cylChildren), 1)
self.assertNotIn("cubeXform", childrenNames(cylChildren))

verifyInitialSetup()

# Parent cube to cylinder by passing the cube but not the cylinder
# while the cylinder is selected.
cmds.select("|mayaUsdProxy1|mayaUsdProxyShape1,/cylinderXform")
cmds.parent("|mayaUsdProxy1|mayaUsdProxyShape1,/cubeXform")

def verifyCubeUnderCylinder():
'''Verify that the cube is under the cylinder.'''
cylHier = ufe.Hierarchy.hierarchy(cylinderItem)
cylChildren = cylHier.children()
self.assertEqual(len(cylChildren), 2)
self.assertIn("cubeXform", childrenNames(cylChildren))

# Confirm that the cube is now a child of the cylinder.
verifyCubeUnderCylinder()

# Undo: the cube is no longer a child of the cylinder.
cmds.undo()
verifyInitialSetup()

# Redo: the cube is again a child of the cylinder.
cmds.redo()
verifyCubeUnderCylinder()

def testParentToProxyShape(self):

# Load a file with a USD hierarchy at least 2-levels deep.
Expand Down

0 comments on commit edd8354

Please sign in to comment.