Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EMSUSD-134 unit test for parent to selection #3558

Merged
merged 2 commits into from
Jan 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.ufeSupportFixLevel() >= 8, 'Requires parent command fix in Maya.')
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