Esempio n. 1
0
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(),
    ]
Esempio n. 2
0
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])
Esempio n. 3
0
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])