def test_repeat_sequential_state(): w1 = WaitState('w1', 0.3) w2 = WaitState('w2', 0.3) seqs = SequentialState('seqs', [w1, w2]) seqs.start(None) seqs.wait(1) info = seqs.get_debug_info() assert info['children'][0]['status'] == StateStatus.SUCCESS assert info['children'][1]['status'] == StateStatus.SUCCESS seqs.start(None) seqs.wait(0.1) info = seqs.get_debug_info() assert info['children'][0]['status'] == StateStatus.RUNNING assert info['children'][1]['status'] == StateStatus.NOT_RUNNING
def test_interruption_in_sequential_state(capsys): ws1 = WaitState("ws1", 0.1) ws2 = WaitState("ws2", 0.1) ps1 = PrintState("ps1", "Print1") sm = SequentialState("sm", children=[ws1, ws2, ps1]) sm.start(None) sm.wait(0.15) sm.interrupt() assert capsys.readouterr().out == "" assert sm.checkStatus(StateStatus.INTERRUPTED) assert ws2.checkStatus(StateStatus.INTERRUPTED) assert ws1.checkStatus(StateStatus.SUCCESS) assert ps1.checkStatus(StateStatus.UNKNOWN) assert not sm._run_thread.is_alive() assert not ws1._run_thread.is_alive() assert not ws2._run_thread.is_alive()
def test_sequential_debug_info(): w1 = WaitState('w1', 1) w2 = WaitState('w2', 1) seqs = SequentialState('seqs', [w1, w2]) seqs.start(None) seqs.wait(0.1) info = seqs.get_debug_info() assert info['name'] == 'seqs' assert len(info['children']) == 2 assert info['children'][0]['name'] == 'w1' assert info['children'][0]['status'] == StateStatus.RUNNING assert info['children'][1]['name'] == 'w2' assert info['children'][1]['status'] == StateStatus.UNKNOWN seqs.wait(1) info = seqs.get_debug_info() assert info['children'][0]['status'] == StateStatus.SUCCESS assert info['children'][1]['status'] == StateStatus.RUNNING seqs.wait()