예제 #1
0
파일: test_actions.py 프로젝트: kervi/kervi
def test_action_async():
    global P1, P2, K1
    spine = MockupSpine()
    set_spine(spine)

    configuration = get_test_config()
    P1 = "a"
    P2 = "b"
    K1 = "c"

    @action
    def action_func_async(p1, p2, **kwargs):
        global P1, P2, K1, event
        time.sleep(2)
        P1 = p1
        P2 = p2
        K1 = kwargs.get("k1", None)
        event.set()

    spine.clear()
    Actions["action_func_async"]("axa", "bxa", k1="kxa", run_async=True)
    assert P1 == "a"
    assert P2 == "b"
    assert K1 == "c"
    event.wait(5)

    assert P1 == "axa"
    assert P2 == "bxa"
    assert K1 == "kxa"
예제 #2
0
파일: test_actions.py 프로젝트: kervi/kervi
def test_action_messages():
    spine = MockupSpine()
    set_spine(spine)

    configuration = get_test_config()

    @action
    def action_func(p1, p2, **kwargs):
        global P1, P2, K1
        P1 = p1
        P2 = p2
        K1 = kwargs.get("k1", None)

    spine.clear()
    Actions["action_func"]("ax", "bx", k1="kx")

    commands = spine.get_send_commands("messageManagerSend")
    assert P1 == "ax"
    assert P2 == "bx"
    assert K1 == "kx"
    assert len(commands) == 2