Ejemplo n.º 1
0
def test_Command_execute(Popen, out):
    """
    Test the Command.execute method
    """
    from paradrop.backend.pdconfd.config.command import Command

    proc = MagicMock()
    proc.stdout = ["output"]
    proc.stderr = ["error"]
    Popen.return_value = proc

    command = Command(["callme"])
    command.parent = MagicMock()

    command.execute()
    assert out.verbose.called_once_with("callme: output")
    assert out.verbose.called_once_with("callme: error")
    assert command.parent.executed.append.called

    Popen.side_effect = Exception("Boom!")
    command.execute()
    assert out.info.called