def setUp(self): super(TestImapTransport, self).setUp() self.arbitrary_hostname = 'one.two.three' self.arbitrary_port = 100 self.ssl = False self.transport = ImapTransport(self.arbitrary_hostname, self.arbitrary_port, self.ssl) self.transport.server = self.imap_server
def setUp(self): super(TestMaxSizeImapTransport, self).setUp() self.transport = ImapTransport( self.arbitrary_hostname, self.arbitrary_port, self.ssl, ) self.transport.server = self.imap_server
def setUp(self): super(TestImapArchivedTransport, self).setUp() self.archive = 'Archive' self.transport = ImapTransport(self.arbitrary_hostname, self.arbitrary_port, self.ssl, self.archive) self.transport.server = self.imap_server
class TestMaxSizeImapTransport(TestImapTransport): @override_settings(DJANGO_MAILBOX_MAX_MESSAGE_SIZE=5807) def setUp(self): super(TestMaxSizeImapTransport, self).setUp() self.transport = ImapTransport( self.arbitrary_hostname, self.arbitrary_port, self.ssl, ) self.transport.server = self.imap_server def test_size_limit(self): all_message_ids = self.transport._get_all_message_ids() small_message_ids = self.transport._get_small_message_ids( all_message_ids, ) self.assertEqual(len(small_message_ids), 1) def test_get_email_message(self): actual_messages = list(self.transport.get_message()) self.assertEqual(len(actual_messages), 1) actual_message = actual_messages[0] expected_message = self._get_email_object('generic_message.eml') self.assertEqual(expected_message, actual_message)
class TestImapTransport(IMAPTestCase): def setUp(self): super(TestImapTransport, self).setUp() self.arbitrary_hostname = 'one.two.three' self.arbitrary_port = 100 self.ssl = False self.transport = ImapTransport(self.arbitrary_hostname, self.arbitrary_port, self.ssl) self.transport.server = self.imap_server def test_get_email_message(self): actual_messages = list(self.transport.get_message()) self.assertEqual(len(actual_messages), 27) actual_message = actual_messages[0] expected_message = self._get_email_object('generic_message.eml') self.assertEqual(expected_message, actual_message)
def get_connection(self): """Returns the transport instance for this mailbox. These will always be instances of `django_mail_admin.transports.base.EmailTransport`. """ if not self.uri: return None elif self.type == 'imap': conn = ImapTransport(self.location, port=self.port if self.port else None, ssl=self.use_ssl, tls=self.use_tls, archive=self.archive, folder=self.folder) conn.connect(self.username, self.password) elif self.type == 'gmail': conn = GmailImapTransport(self.location, port=self.port if self.port else None, ssl=True, archive=self.archive) conn.connect(self.username, self.password) elif self.type == 'pop3': conn = Pop3Transport(self.location, port=self.port if self.port else None, ssl=self.use_ssl) conn.connect(self.username, self.password) elif self.type == 'maildir': conn = MaildirTransport(self.location) elif self.type == 'mbox': conn = MboxTransport(self.location) elif self.type == 'babyl': conn = BabylTransport(self.location) elif self.type == 'mh': conn = MHTransport(self.location) elif self.type == 'mmdf': conn = MMDFTransport(self.location) return conn