from __future__ import unicode_literals
+from mock import Mock
+
from .imapclient_test import IMAPClientTest
self.client._imap.status.assert_called_once_with(b'"foo"', '(UIDNEXT)')
self.assertDictEqual(out, {b'UIDNEXT': 4})
+
+ def test_extra_response(self):
+ # In production, we've seen folder names containing spaces come back
+ # like this and be broken into two components in the tuple.
+ server_response = ["My files (UIDNEXT 24369)"]
+ mock = Mock(return_value=server_response)
+ self.client._command_and_check = mock
+
+ resp = self.client.folder_status('My files', ['UIDNEXT'])
+ self.assertEqual(resp, {'UIDNEXT': 24369})
+
+ # We've also seen the response contain mailboxes we didn't
+ # ask for. In all known cases, the desired mailbox is last.
+ server_response = ["sent (UIDNEXT 24369)\nINBOX (UIDNEXT 24369)"]
+ mock = Mock(return_value=server_response)
+ self.client._command_and_check = mock
+
+ resp = self.client.folder_status('INBOX', ['UIDNEXT'])
+ self.assertEqual(resp, {'UIDNEXT': 24369})
self.assertEqual(folders, [((br'\HasNoChildren',), b'/', 'last')])
-class TestFolderStatus(IMAPClientTest):
- def test_extra_response(self):
- # In production, we've seen folder names containing spaces come back
- # like this and be broken into two components in the tuple.
- server_response = ["My files (UIDNEXT 24369)"]
- mock = Mock(return_value=server_response)
- self.client._command_and_check = mock
-
- resp = self.client.folder_status('My files', ['UIDNEXT'])
- self.assertEqual(resp, {'UIDNEXT': 24369})
-
- # We've also seen the response contain mailboxes we didn't
- # ask for. In all known cases, the desired mailbox is last.
- server_response = ["sent (UIDNEXT 24369)\nINBOX (UIDNEXT 24369)"]
- mock = Mock(return_value=server_response)
- self.client._command_and_check = mock
-
- resp = self.client.folder_status('INBOX', ['UIDNEXT'])
- self.assertEqual(resp, {'UIDNEXT': 24369})
-
-
class TestSelectFolder(IMAPClientTest):
def test_normal(self):