Move remaining mocked objects to mocks.py module
Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
@@ -34,3 +34,32 @@ class MockIMAPServer(object):
|
||||
|
||||
def logout(self):
|
||||
return ('BYE', ['LOGOUT Requested'])
|
||||
|
||||
|
||||
class MockMailbox(object):
|
||||
def dele(self, which):
|
||||
return
|
||||
|
||||
def getwelcome(self):
|
||||
return
|
||||
|
||||
def list(self, which=None):
|
||||
return (None, ['1 test'])
|
||||
|
||||
def user(self, user):
|
||||
return
|
||||
|
||||
def pass_(self, pswd):
|
||||
return
|
||||
|
||||
def quit(self):
|
||||
return
|
||||
|
||||
def retr(self, which=None):
|
||||
return (
|
||||
1, [TEST_EMAIL_BASE64_FILENAME]
|
||||
)
|
||||
|
||||
|
||||
class MockStagingFolder(object):
|
||||
"""Mock of a StagingFolder model"""
|
||||
|
||||
@@ -9,6 +9,8 @@ from mayan.apps.storage.utils import mkdtemp
|
||||
|
||||
from ..classes import StagingFile
|
||||
|
||||
from .mocks import MockStagingFolder
|
||||
|
||||
|
||||
class StagingFileTestCase(BaseTestCase):
|
||||
def test_unicode_staging_file(self):
|
||||
@@ -17,9 +19,6 @@ class StagingFileTestCase(BaseTestCase):
|
||||
|
||||
filename = os.path.basename(TEST_NON_ASCII_DOCUMENT_PATH)
|
||||
|
||||
class MockStagingFolder(object):
|
||||
self.folder_path = temporary_directory
|
||||
|
||||
staging_file_1 = StagingFile(
|
||||
staging_folder=MockStagingFolder(),
|
||||
filename=filename
|
||||
|
||||
@@ -29,7 +29,7 @@ from ..literals import SOURCE_UNCOMPRESS_CHOICE_Y
|
||||
from ..models.email_sources import EmailBaseModel, IMAPEmail, POP3Email
|
||||
from ..models.watch_folder_sources import WatchFolderSource
|
||||
|
||||
from .mocks import MockIMAPServer
|
||||
from .mocks import MockIMAPServer, MockMailbox
|
||||
|
||||
|
||||
from .literals import (
|
||||
@@ -288,33 +288,9 @@ class IMAPSourceTestCase(GenericDocumentTestCase):
|
||||
class POP3SourceTestCase(GenericDocumentTestCase):
|
||||
auto_upload_document = False
|
||||
|
||||
class MockMailbox(object):
|
||||
def dele(self, which):
|
||||
return
|
||||
|
||||
def getwelcome(self):
|
||||
return
|
||||
|
||||
def list(self, which=None):
|
||||
return (None, ['1 test'])
|
||||
|
||||
def user(self, user):
|
||||
return
|
||||
|
||||
def pass_(self, pswd):
|
||||
return
|
||||
|
||||
def quit(self):
|
||||
return
|
||||
|
||||
def retr(self, which=None):
|
||||
return (
|
||||
1, [TEST_EMAIL_BASE64_FILENAME]
|
||||
)
|
||||
|
||||
@mock.patch('poplib.POP3_SSL', autospec=True)
|
||||
def test_download_document(self, mock_poplib):
|
||||
mock_poplib.return_value = POP3SourceTestCase.MockMailbox()
|
||||
mock_poplib.return_value = MockMailbox()
|
||||
self.source = POP3Email.objects.create(
|
||||
document_type=self.test_document_type, label='', host='', password='',
|
||||
username=''
|
||||
|
||||
Reference in New Issue
Block a user