Exemplo n.º 1
0
 def test_start_exit(self, mock_popen):
     proc = MockProcess(2, 'ssh test')
     mock_popen.return_value = proc
     proc.returncode = 1
     tunnel = Tunnel('host', 5000)
     tunnel.start()
     assert tunnel.pid is None
Exemplo n.º 2
0
    def test_start(self, mock_popen, mock_process):
        proc = MockProcess(2, 'ssh')
        mock_popen.return_value = proc
        mock_process.return_value = proc

        tunnel = Tunnel('host', 8080)
        tunnel.start()
        assert tunnel.is_alive()
        mock_popen.assert_called_once_with(
            ['ssh', '-NL', '8080:localhost:8080', 'host'],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE)
        mock_process.assert_called()
Exemplo n.º 3
0
 def test_start_fail(self, mock_popen):
     mock_popen.side_effect = OSError("no such file")
     tunnel = Tunnel('host', 8080)
     tunnel.start()
     assert not tunnel.is_alive()
     assert tunnel.pid is None