예제 #1
0
def test_close_and_terminate():
    """Sends 'exit' and terminates the pexpect connection object."""

    runner = Bladerunner()
    sshc = Mock()
    runner.close(sshc, True)
    sshc.sendline.assert_called_once_with("exit")
    assert sshc.terminate.called
예제 #2
0
def test_close_and_terminate():
    """Sends 'exit' and terminates the pexpect connection object."""

    runner = Bladerunner()
    sshc = Mock()
    runner.close(sshc, True)
    sshc.sendline.assert_called_once_with("exit")
    assert sshc.terminate.called
예제 #3
0
def test_close_keep_open(pexpect_exceptions):
    """Ensure we can close a connection inside another, for jumpboxes."""

    runner = Bladerunner()
    sshc = Mock()
    # exceptions are ignored here, we hope we're back on the jumpbox
    sshc.expect = Mock(side_effect=pexpect_exceptions("mock exception"))

    runner.close(sshc, False)
    sshc.sendline.assert_called_once_with("exit")
    sshc.expect.assert_called_once_with(
        runner.options["shell_prompts"] + runner.options["extra_prompts"],
        runner.options["cmd_timeout"],
    )
예제 #4
0
def test_close_keep_open(pexpect_exceptions):
    """Ensure we can close a connection inside another, for jumpboxes."""

    runner = Bladerunner()
    sshc = Mock()
    # exceptions are ignored here, we hope we're back on the jumpbox
    sshc.expect = Mock(side_effect=pexpect_exceptions("mock exception"))

    runner.close(sshc, False)
    sshc.sendline.assert_called_once_with("exit")
    sshc.expect.assert_called_once_with(
        runner.options["shell_prompts"] +
        runner.options["extra_prompts"],
        runner.options["cmd_timeout"],
    )