Here are the examples of the python api twisted.conch.endpoints._NewConnectionHelper taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
7 Examples
3
Source : test_endpoints.py
with MIT License
from autofelix
with MIT License
from autofelix
def test_defaultKnownHosts(self):
"""
L{_NewConnectionHelper._knownHosts} is used to create a
L{KnownHostsFile} if one is not passed to the initializer.
"""
result = object()
self.patch(_NewConnectionHelper, '_knownHosts', lambda cls: result)
helper = _NewConnectionHelper(
None, None, None, None, None, None, None, None, None, None)
self.assertIs(result, helper.knownHosts)
def test_readExisting(self):
3
Source : test_endpoints.py
with MIT License
from autofelix
with MIT License
from autofelix
def test_defaultConsoleUI(self):
"""
If L{None} is passed for the C{ui} parameter to
L{_NewConnectionHelper}, a L{ConsoleUI} is used.
"""
helper = _NewConnectionHelper(
None, None, None, None, None, None, None, None, None, None)
self.assertIsInstance(helper.ui, ConsoleUI)
def test_ttyConsoleUI(self):
3
Source : test_endpoints.py
with MIT License
from autofelix
with MIT License
from autofelix
def test_ttyConsoleUI(self):
"""
If L{None} is passed for the C{ui} parameter to L{_NewConnectionHelper}
and /dev/tty is available, the L{ConsoleUI} used is associated with
/dev/tty.
"""
tty = _PTYPath(b"yes")
helper = _NewConnectionHelper(
None, None, None, None, None, None, None, None, None, None, tty)
result = self.successResultOf(helper.ui.prompt(b"does this work?"))
self.assertTrue(result)
def test_nottyUI(self):
3
Source : test_endpoints.py
with MIT License
from autofelix
with MIT License
from autofelix
def test_nottyUI(self):
"""
If L{None} is passed for the C{ui} parameter to L{_NewConnectionHelper}
and /dev/tty is not available, the L{ConsoleUI} used is associated with
some file which always produces a C{b"no"} response.
"""
tty = FilePath(self.mktemp())
helper = _NewConnectionHelper(
None, None, None, None, None, None, None, None, None, None, tty)
result = self.successResultOf(helper.ui.prompt(b"did this break?"))
self.assertFalse(result)
def test_defaultTTYFilename(self):
3
Source : test_endpoints.py
with MIT License
from autofelix
with MIT License
from autofelix
def test_defaultTTYFilename(self):
"""
If not passed the name of a tty in the filesystem,
L{_NewConnectionHelper} uses C{b"/dev/tty"}.
"""
helper = _NewConnectionHelper(
None, None, None, None, None, None, None, None, None, None)
self.assertEqual(FilePath(b"/dev/tty"), helper.tty)
def test_cleanupConnectionNotImmediately(self):
3
Source : test_endpoints.py
with MIT License
from autofelix
with MIT License
from autofelix
def test_cleanupConnectionNotImmediately(self):
"""
L{_NewConnectionHelper.cleanupConnection} closes the transport cleanly
if called with C{immediate} set to C{False}.
"""
helper = _NewConnectionHelper(
None, None, None, None, None, None, None, None, None, None)
connection = SSHConnection()
connection.transport = StringTransport()
helper.cleanupConnection(connection, False)
self.assertTrue(connection.transport.disconnecting)
def test_cleanupConnectionImmediately(self):
0
Source : test_endpoints.py
with MIT License
from autofelix
with MIT License
from autofelix
def test_cleanupConnectionImmediately(self):
"""
L{_NewConnectionHelper.cleanupConnection} closes the transport with
C{abortConnection} if called with C{immediate} set to C{True}.
"""
class Abortable:
aborted = False
def abortConnection(self):
"""
Abort the connection.
"""
self.aborted = True
helper = _NewConnectionHelper(
None, None, None, None, None, None, None, None, None, None)
connection = SSHConnection()
connection.transport = SSHClientTransport()
connection.transport.transport = Abortable()
helper.cleanupConnection(connection, True)
self.assertTrue(connection.transport.transport.aborted)