def test_sequential_commands__abort_on_error_1(tmp_path): cmd_1 = AtomicCmd("false") cmd_2 = AtomicCmd(("sleep", 10)) cmd_3 = AtomicCmd(("sleep", 10)) cmds = SequentialCmds([cmd_1, cmd_2, cmd_3]) cmds.run(tmp_path) assert cmds.join() == [1, None, None]
def test_sequential_commands__abort_on_error_3(tmp_path): cmd_1 = AtomicCmd("true") cmd_2 = AtomicCmd("true") cmd_3 = AtomicCmd("false") cmds = SequentialCmds([cmd_1, cmd_2, cmd_3]) cmds.run(tmp_path) assert cmds.join() == [0, 0, 1]
def test_sequential_commands__abort_on_error_3(temp_folder): cmd_1 = AtomicCmd("true") cmd_2 = AtomicCmd("true") cmd_3 = AtomicCmd("false") cmds = SequentialCmds([cmd_1, cmd_2, cmd_3]) cmds.run(temp_folder) assert_equal(cmds.join(), [0, 0, 1])
def test_sequential_commands__atomiccmds(): mock = Mock() cmd_1 = AtomicCmd(["ls"]) cmd_1.run = mock.run_1 cmd_1.join = mock.join_1 cmd_1.join.return_value = [0] cmd_2 = AtomicCmd(["ls"]) cmd_2.run = mock.run_2 cmd_2.join = mock.join_2 cmd_2.join.return_value = [0] cmd_3 = AtomicCmd(["ls"]) cmd_3.run = mock.run_3 cmd_3.join = mock.join_3 cmd_3.join.return_value = [0] cmds = SequentialCmds((cmd_1, cmd_2, cmd_3)) assert not cmds.ready() cmds.run("xTMPx") assert cmds.ready() assert cmds.join() == [0, 0, 0] assert mock.mock_calls == [ call.run_1("xTMPx"), call.join_1(), call.run_2("xTMPx"), call.join_2(), call.run_3("xTMPx"), call.join_3(), call.join_1(), call.join_2(), call.join_3(), ]
def test_sequential_commands__abort_on_error_1(temp_folder): cmd_1 = AtomicCmd("false") cmd_2 = AtomicCmd(("sleep", 10)) cmd_3 = AtomicCmd(("sleep", 10)) cmds = SequentialCmds([cmd_1, cmd_2, cmd_3]) cmds.run(temp_folder) assert_equal(cmds.join(), [1, None, None])
def test_sequential_commands__atomiccmds(): mocks = [] for _ in range(3): cmd_mock = flexmock(AtomicCmd(["ls"])) cmd_mock.should_receive('run').with_args("xTMPx").once cmd_mock.should_receive('join').with_args().and_return([0]).twice mocks.append(cmd_mock) cmds = SequentialCmds(mocks) assert not cmds.ready() cmds.run("xTMPx") assert cmds.ready() assert_equal(cmds.join(), [0, 0, 0])