def test_newMessage_error(self): m = Maildir('/path/to/maildir') def open(*args): raise OSError(errno.EADDRINUSE, "") self.fake_os_module.open = open with self.assertRaises(OSError) as exc: m.newMessage() self.assertEqual(exc.exception.errno, errno.EADDRINUSE)
def test_newMessage(self): from zope.sendmail.maildir import Maildir from zope.sendmail.interfaces import IMaildirMessageWriter m = Maildir('/path/to/maildir') fd = m.newMessage() verifyObject(IMaildirMessageWriter, fd) self.assertTrue(fd._filename.startswith( '/path/to/maildir/tmp/1234500002.4242.myhostname.'))
def createDataManager(self, fromaddr, toaddrs, message): maildir = Maildir(self.queuePath, True) msg = maildir.newMessage() msg.write('X-Zope-From: %s\n' % fromaddr) msg.write('X-Zope-To: %s\n' % ", ".join(toaddrs)) msg.write(message) msg.close() return MailDataManager(msg.commit, onAbort=msg.abort)
def test_newMessage(self): from zope.sendmail.maildir import Maildir from zope.sendmail.interfaces import IMaildirMessageWriter m = Maildir('/path/to/maildir') fd = m.newMessage() verifyObject(IMaildirMessageWriter, fd) self.assert_( fd._filename.startswith( '/path/to/maildir/tmp/1234500002.4242.myhostname.'))
def test_newMessage(self): m = Maildir('/path/to/maildir') fd = m.newMessage() verifyObject(IMaildirMessageWriter, fd) self.assertTrue(fd._filename.startswith( '/path/to/maildir/tmp/1234500002.4242.myhostname.'))