Ejemplo n.º 1
0
def test_createStateMachineInstance():
    print("Create StateMachine Instance:", end=" ")
    try:
        sm = StateMachine("test")
        assert sm.getName() == "test"
        print("SUCCESSED")
    except:
        print("FAILED")
        assert False
Ejemplo n.º 2
0
def test_addStateToSM():
    print("Add State To StateMachine Instance:", end=" ")
    try:
        sm = StateMachine("test")
        s = State()
        sm.addState(s)
        assert len(sm.getStates()) == 1
        print("SUCCESSED")
    except:
        print("FAILED")
        assert False
Ejemplo n.º 3
0
def test_addTransitionToSM():
    print("Add Transition To StateMachine Instance:", end=" ")
    try:
        sm = StateMachine("test")
        t = Transition()
        t.setInOutID(None, 0)
        sm.addTransition(t)
        assert len(sm.getTransitions()) == 1
        print("SUCCESSED")
    except:
        print("FAILED")
        assert False
Ejemplo n.º 4
0
def test_runSimpleSM():
    print("Run Simple StateMachine:", end=" ")
    try:
        sm = StateMachine("test")
        s = State()
        s.addAction(act)
        t1 = Transition()
        t1.setInOutID(inf, s.getID())
        t1.addEvaluation(ev)
        t2 = Transition()
        t2.setInOutID(s.getID(), -inf)
        t2.addEvaluation(ev)
        sm.addState(s)
        sm.addTransition(t1)
        sm.addTransition(t2)
        assert len(sm.getStates()) == 1 and len(sm.getTransitions()) == 2
        sm.start()
        print("SUCCESSED")
        assert True
    except:
        print("FAILED")
        assert False
Ejemplo n.º 5
0
def test_simpleSM():
    print("Create Simple StateMachine:", end=" ")
    try:
        sm = StateMachine("test")
        s = State()
        t1 = Transition()
        t1.setInOutID(None, s.getID())
        t2 = Transition()
        t2.setInOutID(s.getID(), None)
        sm.addState(s)
        sm.addTransition(t1)
        sm.addTransition(t2)
        assert len(sm.getStates()) == 1 and len(sm.getTransitions()) == 2
        print("SUCCESSED")
    except:
        print("FAILED")
        assert False
Ejemplo n.º 6
0
def test_runEncSM():
    print("Run Encapsuled StateMachine:", end=" ")
    try:
        sm = StateMachine("test2")
        sm.loadJSON("./tests/test2.json")
        sm.start()
        print("SUCCESSED")
        assert True
    except:
        print("FAILED")
        assert False
Ejemplo n.º 7
0
def test_loadJSONFile2():
    print("load JSON file 2:", end=" ")
    try:
        sm = StateMachine("test")
        sm.loadJSON("./tests/StateMachine.json")
        sm.start()
        print("SUCCESSED")
        assert True
    except:
        print("FAILED")
        assert False