]> khamidou — GitHub mirrors - imapclient.git/commitdiff
fixed bug that caused breakage with folder names containing unusual chars
authorMenno Smits <menno@pali>
Sun, 19 Apr 2009 12:54:12 +0000 (13:54 +0100)
committerMenno Smits <menno@pali>
Sun, 19 Apr 2009 12:54:12 +0000 (13:54 +0100)
TODO
imapclient/imapclient.py
imapclient/test/test_IMAPClient.py

diff --git a/TODO b/TODO
index 829624cc11ca4718736c04d816e8b2e584427fee..a1dfb81746af3554817dda04d8ae0d997664df28 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,6 +1,4 @@
 - transparent folder escaping
-    - re_folder currently fails if there's strange chars in the folder name
-        - write a unit test for this
     - more testing
         - gmail
         - cyrus
@@ -10,6 +8,9 @@
 
 - sort out INTERNALDATE timezone issues in livetest.py (see freshfoo.com)
 
+- livetest.py --interact support is clumsy
+    - make this a separate command-line utility instead
+
 ---- release 0.5 ----
 
 - automate releases with bzr
@@ -19,6 +20,7 @@
 - clean up basic command handling to avoid repetition
 - might be able to metaprogram the way out of the currently clumsy UID handling situation
 - sphinx based docs
+    - publish on web site too
 - support for more IMAP functions: sort, examine etc
     - someone sent a patch for this?
 - write a comparision of imaplib vs imapclient.py
index 24eac207c0c80882c1a4ff464dafb5bf17fbad07..2234b7244304911fb5cd753acc74ab6e66b87df6 100644 (file)
@@ -163,15 +163,14 @@ class IMAPClient(object):
 
         folders = []
         for line in data:
+            #TODO can the FetchParser code be adapted for use here?
             folder_text = None
-            #XXX write a unit test for this bug
-            #XXX can the FetchParser code be used here instead?
-            #if isinstance(line, tuple):
-                #folder_text = line[-1]
-            #else:
-            m = self.re_folder.match(line)
-            if m:
-                folder_text = m.group(1)
+            if isinstance(line, tuple):
+                folder_text = line[-1]
+            else:
+                match = self.re_folder.match(line)
+                if match:
+                    folder_text = match.group(1)
             if folder_text is not None:
                 folders.append(self._decode_folder_name(folder_text))
         return folders
index 4f113ce382981a9783a89bcf7a9f9bcd192d5607..5cb7070fedc66a4b1c6c72ca1151d362cf0982ce 100644 (file)
@@ -1,11 +1,12 @@
 import unittest
-from imapclient.test.testable_imapclient import TestableIMAPClient
+from imapclient.test.testable_imapclient import TestableIMAPClient as IMAPClient
 from imapclient.test.mock import sentinel
 
+
 class IMAPClientTestBase(unittest.TestCase):
 
     def setUp(self):
-        self.client = TestableIMAPClient()
+        self.client = IMAPClient()
 
 
 class TestListFolders(IMAPClientTestBase):
@@ -21,6 +22,11 @@ class TestListFolders(IMAPClientTestBase):
         self.assert_(folders == ['A', 'Foo Bar'])
 
 
+    def test_NO(self):
+        self.client._imap.list.return_value = ('NO', ['badness'])
+        self.assertRaises(IMAPClient.Error, self.client.list_folders)
+
+
     def test_without_quotes(self):
         self.client._imap.list.return_value = ('OK', ['(\\HasNoChildren) "/" A',
                                                       '(\\HasNoChildren) "/" B',
@@ -41,10 +47,15 @@ class TestListFolders(IMAPClientTestBase):
         self.assert_(folders == ['Alpha', 'Foo Bar', 'C'], 'got %r' % folders)
 
 
-class TestListFolders(IMAPClientTestBase):
+    def test_funky_characters(self):
+        self.client._imap.list.return_value = ('OK',
+                                               [('(\\NoInferiors \\UnMarked) "/" {5}', 'bang\xff'),
+                                                '',
+                                                '(\\HasNoChildren \\UnMarked) "/" "INBOX"'])
+
+        folders = self.client.list_folders()
+        self.assert_(folders == ['bang\xff', 'INBOX'], 'got %r' % folders)
 
-    def test_fail(self):
-        self.assert_(False, 'todo')
 
 
 if __name__ == '__main__':