]> khamidou — GitHub mirrors - imapclient.git/commitdiff
Add tests and documentation updates for pull request #8
authorSpotlightKid <bitbucket@chrisarndt.de>
Wed, 3 Sep 2014 21:54:49 +0000 (23:54 +0200)
committerSpotlightKid <bitbucket@chrisarndt.de>
Wed, 3 Sep 2014 21:54:49 +0000 (23:54 +0200)
doc/src/conf.py
imapclient/imapclient.py
imapclient/test/test_init.py

index 7329c7145ba21dc464a745ca24e217ec7620961a..a50c1cad7f9ca40f607040d49d5af5f7356c6cb1 100644 (file)
@@ -17,7 +17,10 @@ import imapclient
 
 # Add any Sphinx extension module names here, as strings. They can be extensions
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
-extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode']
+extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode',
+    'sphinx.ext.intersphinx']
+
+intersphinx_mapping = {'python':('http://docs.python.org/3', None)}
 
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']
index 5aef0f6cbe98f3818229a0a562a13e483f6293d5..8288870c154ef1a3664f5cf090f3cf264c2b8c87 100644 (file)
@@ -78,6 +78,17 @@ class IMAPClient(object):
     ``False``). This is useful for exotic connection or authentication
     setups.
 
+    Additional keyword arguments are passed to the constructor of the
+    :py:class:`imaplib.IMAP4` class, resp. :py:class:`imaplib.IMAP4_SSL` when
+    *ssl* is ``True``, which is used by ``IMAPClient`` internally. This allows
+    passing SSL related parameters, i.e. *keyfile* and *certfile* or an
+    :py:class:`ssl.SSLContext` instance with *ssl_context*. Please note that
+    some keyword arguments of the :py:class:`imaplib.IMP4_SSL` init method are
+    only supported in newer Python versions, in particular, the *ssl_context*
+    argument was added in Python 3.3. The class :py:class:`imaplib.IMAP4` (no
+    SSL) does not accept any additional keyword arguments. For details, see the
+    :py:mod:`imaplib` documentation in the standard library reference.
+
     The *normalise_times* attribute specifies whether datetimes
     returned by ``fetch()`` are normalised to the local system time
     and include no timezone information (native), or are datetimes
index 12061c8f1954278c1260efd3dbe5dc4a2a9670eb..e4b3ddf847c848f7c0a0ade0f97aecc0ee9ebf42 100644 (file)
@@ -40,6 +40,25 @@ class TestInit(unittest.TestCase):
         self.assertEqual(imap.ssl, True)
         self.assertEqual(imap.stream, False)
 
+    def test_SSL_kwargs(self):
+        self.imaplib.IMAP4_SSL.return_value = sentinel.IMAP4_SSL
+
+        imap = IMAPClient('1.2.3.4', ssl=True, keyfile='key.pem',
+                          certfile='cert.pem')
+
+        self.assertEqual(imap._imap, sentinel.IMAP4_SSL)
+        self.imaplib.IMAP4_SSL.assert_called_with('1.2.3.4', 993,
+            keyfile='key.pem', certfile='cert.pem')
+        self.assertEqual(imap.ssl, True)
+        self.assertEqual(imap.stream, False)
+
+        imap = IMAPClient('1.2.3.4', ssl=True, ssl_context=None)
+        self.imaplib.IMAP4_SSL.assert_called_with('1.2.3.4', 993,
+            ssl_context=None)
+        self.assertEqual(imap.ssl, True)
+        self.assertEqual(imap.stream, False)
+
+
     def test_stream(self):
         self.imaplib.IMAP4_stream.return_value = sentinel.IMAP4_stream