Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    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)