def test_expose_element_attr(cmds): """Validate we can export an element attribute to a single attribute.""" src = cmds.createNode("network", name="src") dst = cmds.createNode("network", name="dst") attr_name = "testMultiAttr" cmds.addAttr(src, longName=attr_name, multi=True) expose_attribute(src, dst, attr_name) is_multi = cmds.attributeQuery(attr_name, node=dst, multi=True) assert not is_multi
def test_transfer_attribute_single_scalar(): """ Validate we can transfer a simple scalar attribute. """ src = cmds.createNode("transform", name="src") dst = cmds.createNode("transform", name="dst") cmds.addAttr(src, longName="test") expose_attribute(src, dst, "test") assert cmds.objExists("dst.test")
def test_transform_attribute_child_scalar_to_single_scalar(): """ Validate we can transfer an attribute child of another attribute to a single isolated attribute. """ src = cmds.createNode("transform", name="src") dst = cmds.createNode("transform", name="dst") cmds.addAttr(src, longName="test", at="float2") cmds.addAttr(src, longName="testX", at="float", parent="test") cmds.addAttr(src, longName="testY", at="float", parent="test") expose_attribute(src, dst, "testY") assert cmds.objExists("dst.testY")
def test_expose_compound_attr(cmds): """Validate we can export a simple compound attribute.""" src = cmds.createNode("transform", name="src") dst = cmds.createNode("network", name="dst") expose_attribute(src, dst, "translate") assert cmds.objExists("dst.translate") assert cmds.objExists("dst.translateX") assert cmds.objExists("dst.translateY") assert cmds.objExists("dst.translateZ") assert cmds.attributeQuery("translate", node="dst", shortName=True) == "t" assert cmds.attributeQuery("translateX", node="dst", shortName=True) == "tx" assert cmds.attributeQuery("translateY", node="dst", shortName=True) == "ty" assert cmds.attributeQuery("translateZ", node="dst", shortName=True) == "tz"
def test_expose_multiple_compound_attr_with_same_name(cmds): """Validate we can expose two attributes that have the same names.""" src1 = cmds.createNode("transform", name="src1") src2 = cmds.createNode("transform", name="src2") dst = cmds.createNode("network", name="dst") expose_attribute(src1, dst, "translate") expose_attribute(src2, dst, "translate") for long_name, short_name in ( ("translate", "t"), ("translateX", "tx"), ("translateY", "ty"), ("translateZ", "tz"), ("translate1", "t1"), ("translate1X", "t1x"), ("translate1Y", "t1y"), ("translate1Z", "t1z"), ): assert cmds.objExists("dst.%s" % long_name) assert cmds.attributeQuery(short_name, node="dst", shortName=True) == short_name