Fix IMAP4 store flags argument, GitLab issue #606
Python's documentation is incorrect, argument name is flag_list. Closes GitLab issue #606. Thanks to Samuel Aebi (@samuelaebi) for the report and debug information. Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
@@ -20,8 +20,9 @@ from mayan.apps.metadata.models import MetadataType
|
||||
from mayan.apps.storage.utils import mkdtemp
|
||||
|
||||
from ..literals import SOURCE_UNCOMPRESS_CHOICE_Y
|
||||
from ..models import POP3Email, WatchFolderSource, WebFormSource
|
||||
from ..models.email_sources import EmailBaseModel
|
||||
from ..models.email_sources import EmailBaseModel, IMAPEmail, POP3Email
|
||||
from ..models.watch_folder_sources import WatchFolderSource
|
||||
from ..models.webform_sources import WebFormSource
|
||||
|
||||
from .literals import (
|
||||
TEST_EMAIL_ATTACHMENT_AND_INLINE, TEST_EMAIL_BASE64_FILENAME,
|
||||
@@ -60,7 +61,7 @@ class CompressedUploadsTestCase(GenericDocumentTestCase):
|
||||
)
|
||||
|
||||
|
||||
class EmailFilenameDecodingTestCase(GenericDocumentTestCase):
|
||||
class EmailBaseTestCase(GenericDocumentTestCase):
|
||||
auto_upload_document = False
|
||||
|
||||
def _create_email_source(self):
|
||||
@@ -190,6 +191,55 @@ class EmailFilenameDecodingTestCase(GenericDocumentTestCase):
|
||||
self.assertEqual(2, Document.objects.count())
|
||||
|
||||
|
||||
class IMAPSourceTestCase(GenericDocumentTestCase):
|
||||
auto_upload_document = False
|
||||
|
||||
class MockIMAPServer(object):
|
||||
def login(self, user, password):
|
||||
return ('OK', ['{} authenticated (Success)'.format(user)])
|
||||
|
||||
def select(self, mailbox='INBOX', readonly=False):
|
||||
return ('OK', ['1'])
|
||||
|
||||
def search(self, charset, *criteria):
|
||||
return ('OK', ['1'])
|
||||
|
||||
def fetch(self, message_set, message_parts):
|
||||
return (
|
||||
'OK', [
|
||||
(
|
||||
'1 (RFC822 {4800}',
|
||||
TEST_EMAIL_BASE64_FILENAME
|
||||
), ' FLAGS (\\Seen))'
|
||||
]
|
||||
)
|
||||
|
||||
def store(self, message_set, command, flags):
|
||||
return ('OK', ['1 (FLAGS (\\Seen \\Deleted))'])
|
||||
|
||||
def expunge(self):
|
||||
return ('OK', ['1'])
|
||||
|
||||
def close(self):
|
||||
return ('OK', ['Returned to authenticated state. (Success)'])
|
||||
|
||||
def logout(self):
|
||||
return ('BYE', ['LOGOUT Requested'])
|
||||
|
||||
@mock.patch('imaplib.IMAP4_SSL', autospec=True)
|
||||
def test_download_document(self, mock_imaplib):
|
||||
mock_imaplib.return_value = IMAPSourceTestCase.MockIMAPServer()
|
||||
self.source = IMAPEmail.objects.create(
|
||||
document_type=self.test_document_type, label='', host='',
|
||||
password='', username=''
|
||||
)
|
||||
|
||||
self.source.check_source()
|
||||
self.assertEqual(
|
||||
Document.objects.first().label, 'Ampelm\xe4nnchen.txt'
|
||||
)
|
||||
|
||||
|
||||
class POP3SourceTestCase(GenericDocumentTestCase):
|
||||
auto_upload_document = False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user