예제 #1
0
파일: tests.py 프로젝트: fvbehr/cmdx
def test_modifier_badtype():
    """Modifier can't create non-existent types"""

    mod = cmdx.DagModifier()

    # This is the only call that throws an error
    # immediately as it is called. Great!
    assert_raises(TypeError, mod.createNode, "doesntExist")
예제 #2
0
파일: tests.py 프로젝트: fvbehr/cmdx
def test_modifier_first_error():
    """Modifier throws only the first encountered error"""

    mod = cmdx.DagModifier()
    node = mod.createNode("transform")
    mod.connect(node["translateX"], node["translateY"])
    mod.setAttr(node["translateY"], 5.0)

    assert_raises(cmdx.ModifierError, mod.doIt)
예제 #3
0
파일: tests.py 프로젝트: fvbehr/cmdx
def test_modifier_existing_connection():
    """Modifier fails on connecting to already-connected attribute"""

    mod = cmdx.DagModifier()
    node = mod.createNode("transform")
    mod.connect(node["translateX"], node["translateY"])
    mod.connect(node["translateZ"], node["translateY"], force=False)

    assert_raises(cmdx.ModifierError, mod.doIt)
예제 #4
0
파일: tests.py 프로젝트: fvbehr/cmdx
def test_modifier_atomicity():
    """Modifier rolls back changes on failure"""

    mod = cmdx.DagModifier()
    node = mod.createNode("transform", name="UniqueName")
    mod.connect(node["translateX"], node["translateY"])
    mod.setAttr(node["translateY"], 5.0)

    assert_raises(cmdx.ModifierError, mod.doIt)

    # Node got created, even though
    assert "UniqueName" not in cmds.ls()
예제 #5
0
파일: tests.py 프로젝트: fvbehr/cmdx
def test_modifier_history():
    """Modifiers provide record of history on failure"""

    mod = cmdx.DagModifier()
    node = mod.createNode("transform", name="UniqueName")
    mod.connect(node["translateX"], node["translateY"])
    mod.setAttr(node["translateY"], 5.0)

    try:
        mod.doIt()
    except cmdx.ModifierError as e:
        pass

    tasks = [task[0] for task in e.history]
    assert_equals(tasks[0], "createNode")
    assert_equals(tasks[1], "connect")
    assert_equals(tasks[2], "setAttr")