Beispiel #1
0
 def test_small_read_timeout_fail(self):
     """
     For ease, the login operation use the read/write timeout. To make the
     test pass, we don't login once connected but simply try a 'noop', that
     should not be able to complete in under a such a small time.
     """
     self.conf.timeout = SocketTimeout(connect=30, read=0.00001)
     self.client = create_client_from_config(self.conf, login=False)
     with self.assertRaises(socket.timeout):
         self.client.noop()
Beispiel #2
0
    def test_plain(self):
        fakeIMAP4 = Mock()
        self.imap4.IMAP4WithTimeout.return_value = fakeIMAP4

        imap = IMAPClient('1.2.3.4', ssl=False, timeout=sentinel.timeout)

        self.assertEqual(imap._imap, fakeIMAP4)
        self.imap4.IMAP4WithTimeout.assert_called_with(
            '1.2.3.4', 143, SocketTimeout(sentinel.timeout, sentinel.timeout))
        self.assertEqual(imap.host, '1.2.3.4')
        self.assertEqual(imap.port, 143)
        self.assertEqual(imap.ssl, False)
        self.assertEqual(imap.ssl_context, None)
        self.assertEqual(imap.stream, False)
Beispiel #3
0
    def test_SSL(self):
        fakeIMAP4_TLS = Mock()
        self.tls.IMAP4_TLS.return_value = fakeIMAP4_TLS

        imap = IMAPClient('1.2.3.4',
                          ssl_context=sentinel.context,
                          timeout=sentinel.timeout)

        self.assertEqual(imap._imap, fakeIMAP4_TLS)
        self.tls.IMAP4_TLS.assert_called_with(
            '1.2.3.4', 993, sentinel.context,
            SocketTimeout(sentinel.timeout, sentinel.timeout))
        self.assertEqual(imap.host, '1.2.3.4')
        self.assertEqual(imap.port, 993)
        self.assertEqual(imap.ssl, True)
        self.assertEqual(imap.ssl_context, sentinel.context)
        self.assertEqual(imap.stream, False)
Beispiel #4
0
 def test_small_connection_timeout_fail(self):
     self.conf.timeout = SocketTimeout(connect=0.001, read=10)
     with self.assertRaises(socket.timeout):
         self.client = create_client_from_config(self.conf)