コード例 #1
0
    def test_init(self):
        """
        Test that SSHChannel initializes correctly.  localWindowSize defaults
        to 131072 (2**17) and localMaxPacket to 32768 (2**15) as reasonable
        defaults (what OpenSSH uses for those variables).

        The values in the second set of assertions are meaningless; they serve
        only to verify that the instance variables are assigned in the correct
        order.
        """
        c = channel.SSHChannel(conn=self.conn)
        self.assertEqual(c.localWindowSize, 131072)
        self.assertEqual(c.localWindowLeft, 131072)
        self.assertEqual(c.localMaxPacket, 32768)
        self.assertEqual(c.remoteWindowLeft, 0)
        self.assertEqual(c.remoteMaxPacket, 0)
        self.assertEqual(c.conn, self.conn)
        self.assertEqual(c.data, None)
        self.assertEqual(c.avatar, None)

        c2 = channel.SSHChannel(1, 2, 3, 4, 5, 6, 7)
        self.assertEqual(c2.localWindowSize, 1)
        self.assertEqual(c2.localWindowLeft, 1)
        self.assertEqual(c2.localMaxPacket, 2)
        self.assertEqual(c2.remoteWindowLeft, 3)
        self.assertEqual(c2.remoteMaxPacket, 4)
        self.assertEqual(c2.conn, 5)
        self.assertEqual(c2.data, 6)
        self.assertEqual(c2.avatar, 7)
コード例 #2
0
 def test_str(self):
     """
     Test that str(SSHChannel) works gives the channel name and local and
     remote windows at a glance..
     """
     self.assertEqual(str(self.channel), "<SSHChannel channel (lw 131072 rw 0)>")
     self.assertEqual(
         str(channel.SSHChannel(localWindow=1)), "<SSHChannel None (lw 1 rw 0)>"
     )
コード例 #3
0
 def setUp(self):
     """
     Initialize the channel.  remoteMaxPacket is 10 so that data is able
     to be sent (the default of 0 means no data is sent because no packets
     are made).
     """
     self.conn = MockConnection()
     self.channel = channel.SSHChannel(conn=self.conn, remoteMaxPacket=10)
     self.channel.name = 'channel'
コード例 #4
0
ファイル: test_channel.py プロジェクト: yuu6/twisted
    def test_bytes(self):
        """
        Test that bytes(SSHChannel) works, gives the channel name and
        local and remote windows at a glance..

        """
        self.assertEqual(self.channel.__bytes__(),
                         b'<SSHChannel channel (lw 131072 rw 0)>')
        self.assertEqual(
            channel.SSHChannel(localWindow=1).__bytes__(),
            b'<SSHChannel None (lw 1 rw 0)>')