]> khamidou — GitHub mirrors - imapclient.git/commitdiff
Handle HIGHESTMODSEQ in SELECT response correctly
authorMenno Smits <menno@freshfoo.com>
Thu, 30 May 2013 22:25:49 +0000 (23:25 +0100)
committerMenno Smits <menno@freshfoo.com>
Thu, 30 May 2013 22:25:49 +0000 (23:25 +0100)
And added much needed unit tests for select_folder

imapclient/imapclient.py
imapclient/test/test_imapclient.py

index 7675bbeece7baf74e16e87997ee2adc17fbd8063..6d743cbaf255b5938d778c1e4e0a4275b0d6d750 100644 (file)
@@ -363,7 +363,7 @@ class IMAPClient(object):
             key = key.upper()
             if key == 'OK':
                 continue
-            elif key in ('EXISTS', 'RECENT', 'UIDNEXT', 'UIDVALIDITY'):
+            elif key in ('EXISTS', 'RECENT', 'UIDNEXT', 'UIDVALIDITY', 'HIGHESTMODSEQ'):
                 value = int(value[0])
             elif key in ('FLAGS', 'PERMANENTFLAGS'):
                 value = parse_response(value)[0]
index 717f15326e7cc91c44863fa288d828d71078aa98..a11e5d21e3a18f38f1cf0fee50cb92a0f149d995 100644 (file)
@@ -150,6 +150,41 @@ class TestListFolders(IMAPClientTest):
         self.assertEqual(folders, [((r'\HasNoChildren',), '/', 'last')])
 
 
+class TestSelectFolder(IMAPClientTest):
+
+    def test_normal(self):
+        self.client._command_and_check = Mock()
+        self.client._imap.untagged_responses = {
+            'OK': [],
+            'exists': ['1'],
+            'RECENT': ['2'],
+            'UIDNEXT': ['3'],
+            'UIDVALIDITY': ['4'],
+            'HIGHESTMODSEQ': ['5'],
+            'FLAGS': ['(ABC DEF)'],
+            'PERMANENTFLAGS': ['(XXX ZZZ)'],
+            'READ-WRITE': [''],
+            'OTHER': ['blah']
+        }
+
+        result = self.client.select_folder(b'folder_name', sentinel.readonly)
+
+        self.client._command_and_check.assert_called_once_with('select',
+                                                               '"folder_name"',
+                                                               sentinel.readonly)
+        self.assertEqual(result, {
+            'EXISTS': 1,
+            'RECENT': 2,
+            'UIDNEXT': 3,
+            'UIDVALIDITY': 4,
+            'HIGHESTMODSEQ': 5,
+            'FLAGS': ('ABC', 'DEF'),
+            'PERMANENTFLAGS': ('XXX', 'ZZZ'),
+            'READ-WRITE': True,
+            'OTHER': ['blah']
+        })
+
+
 class TestAppend(IMAPClientTest):
 
     def test_without_msg_time(self):