Permalink
Browse files

Merge pull request #363 from Unpublished/find_special_folder_fix

fix find_special_folder
  • Loading branch information...
NicolasLM committed Sep 19, 2018
2 parents 83e6c97 + 6fc303c commit 580dc6781b5bf9d4f2a1a74b5d4168ef9b842b87
Showing with 14 additions and 1 deletion.
  1. +1 −1 imapclient/imapclient.py
  2. +13 −0 tests/test_imapclient.py
View
@@ -641,7 +641,7 @@ def find_special_folder(self, folder_flag):
# TODO: avoid listing all folders by using extended LIST (RFC6154)
if self.has_capability('SPECIAL-USE'):
for folder in self.list_folders():
if folder and len(folder[0]) > 1 and folder[0][1] == folder_flag:
if folder and len(folder[0]) > 0 and folder_flag in folder[0]:
return folder[2]
# Detect folder by looking for common names
View
@@ -170,6 +170,19 @@ def test_find_special_folder_with_special_use(self):
self.assertEqual(folder, "Sent")
def test_find_special_folder_with_special_use_single_flag(self):
self.client._cached_capabilities = (b'SPECIAL-USE',)
self.client._imap._simple_command.return_value = ('OK', [b'something'])
self.client._imap._untagged_response.return_value = (
'LIST', [
b'(\\HasNoChildren) "/" "INBOX"',
b'(\\Sent) "/" "Sent"',
])
folder = self.client.find_special_folder(b'\\Sent')
self.assertEqual(folder, "Sent")
def test_find_special_folder_without_special_use_nor_namespace(self):
self.client._cached_capabilities = (b'FOO',)
self.client._imap._simple_command.return_value = ('OK', [b'something'])

0 comments on commit 580dc67

Please sign in to comment.