def test_noSender(self): """ Test that a message with no sender headers gets handled properly. """ self.msg.addHeader(u"to", u"*****@*****.**") self.msg.addHeader(u"date", u"Fri, 13 Feb 2004 13:43:48 +0100") self.msg.addHeader(u"content-type", u"multipart/mixed") self.msg.addHeader(u"subject", u"Awesome Email") self.wrapper = MessageWrapperForPart(self.msg, Time()) self.assertEqual(self.wrapper.sender, u'') self.assertEqual(self.wrapper.senderDisplay, u'')
def createMIMEStructure(self): """ Insert some contents into the attached message. """ self.msg.addHeader(u"from", u"*****@*****.**") self.msg.addHeader(u"to", u"*****@*****.**") self.msg.addHeader(u"date", u"Fri, 13 Feb 2004 13:43:48 +0100") self.msg.addHeader(u"content-type", u"multipart/mixed") self.msg.addHeader(u"subject", u"Awesome Email") subpart = self.msg.newChild() subpart.addHeader(u"content-type", u"text/html") attachment = self.msg.newChild() attachment.addHeader(u"content-type", u"image/png") attachment.addHeader(u"content-disposition", u'attachment; filename="foo.png"') self.parent._addToStore( self.store, Message(store=self.store), FilePath(self.dbdir).child("files").child("msg")) self.wrapper = MessageWrapperForPart(self.msg, Time())
def test_moreWrapperAttributes(self): """ Test that wrapper attributes are sufficiently like Message's when certain headers aren't present. """ self.msg.addHeader(u"from", u"*****@*****.**") self.msg.addHeader(u"date", u"Fri, 13 Feb 2004 13:43:48 +0100") self.msg.addHeader(u"content-type", u"multipart/mixed") subpart = self.msg.newChild() subpart.addHeader(u"content-type", u"text/html") attachment = self.msg.newChild() attachment.addHeader(u"content-type", u"image/png") attachment.addHeader(u"content-disposition", u'attachment; filename="foo.png"') self.parent._addToStore( self.store, Message(store=self.store), FilePath(self.dbdir).child("files").child("msg")) self.wrapper = MessageWrapperForPart(self.msg, Time()) self.assertEqual(self.wrapper.recipient, u'<No Recipient>') self.assertEqual(self.wrapper.subject, u'<No Subject>')
def createMIMEStructure(self): """ Insert some contents into the attached message. """ self.msg.addHeader(u"from", u"*****@*****.**") self.msg.addHeader(u"to", u"*****@*****.**") self.msg.addHeader(u"date", u"Fri, 13 Feb 2004 13:43:48 +0100") self.msg.addHeader(u"content-type", u"multipart/mixed") self.msg.addHeader(u"subject", u"Awesome Email") subpart = self.msg.newChild() subpart.addHeader(u"content-type", u"text/html") attachment = self.msg.newChild() attachment.addHeader(u"content-type", u"image/png") attachment.addHeader(u"content-disposition", u'attachment; filename="foo.png"') self.parent._addToStore(self.store, Message(store=self.store), FilePath(self.dbdir).child("files").child("msg")) self.wrapper = MessageWrapperForPart(self.msg, Time())
def test_moreWrapperAttributes(self): """ Test that wrapper attributes are sufficiently like Message's when certain headers aren't present. """ self.msg.addHeader(u"from", u"*****@*****.**") self.msg.addHeader(u"date", u"Fri, 13 Feb 2004 13:43:48 +0100") self.msg.addHeader(u"content-type", u"multipart/mixed") subpart = self.msg.newChild() subpart.addHeader(u"content-type", u"text/html") attachment = self.msg.newChild() attachment.addHeader(u"content-type", u"image/png") attachment.addHeader(u"content-disposition", u'attachment; filename="foo.png"') self.parent._addToStore(self.store, Message(store=self.store), FilePath(self.dbdir).child("files").child("msg")) self.wrapper = MessageWrapperForPart(self.msg, Time()) self.assertEqual(self.wrapper.recipient, u'<No Recipient>') self.assertEqual(self.wrapper.subject, u'<No Subject>')
class PartWrapperTestCase(TestCase): """ Tests for L{xquotient.exmess.MessageWrapperForPart}. """ def setUp(self): """ Create a store and a MIME message with a message/rfc822 attachment. """ self.dbdir = self.mktemp() self.store = Store(dbdir=self.dbdir) partCounter = itertools.count().next self.parent = Part(_partCounter=partCounter) msgContainer = self.parent.newChild() msgContainer.addHeader(u"content-type", u"message/rfc822") msgContainer.addHeader(u"content-disposition", u"inline") self.msg = msgContainer.newChild() def createMIMEStructure(self): """ Insert some contents into the attached message. """ self.msg.addHeader(u"from", u"*****@*****.**") self.msg.addHeader(u"to", u"*****@*****.**") self.msg.addHeader(u"date", u"Fri, 13 Feb 2004 13:43:48 +0100") self.msg.addHeader(u"content-type", u"multipart/mixed") self.msg.addHeader(u"subject", u"Awesome Email") subpart = self.msg.newChild() subpart.addHeader(u"content-type", u"text/html") attachment = self.msg.newChild() attachment.addHeader(u"content-type", u"image/png") attachment.addHeader(u"content-disposition", u'attachment; filename="foo.png"') self.parent._addToStore( self.store, Message(store=self.store), FilePath(self.dbdir).child("files").child("msg")) self.wrapper = MessageWrapperForPart(self.msg, Time()) def test_wrapperAttributes(self): """ Test that wrapper attributes are sufficiently like Message's. """ self.createMIMEStructure() self.assertEqual(self.wrapper.impl, self.msg) self.assertEqual(self.wrapper.recipient, u'*****@*****.**') self.assertEqual(self.wrapper.sender, u'*****@*****.**') self.assertEqual(self.wrapper.subject, u'Awesome Email') def test_moreWrapperAttributes(self): """ Test that wrapper attributes are sufficiently like Message's when certain headers aren't present. """ self.msg.addHeader(u"from", u"*****@*****.**") self.msg.addHeader(u"date", u"Fri, 13 Feb 2004 13:43:48 +0100") self.msg.addHeader(u"content-type", u"multipart/mixed") subpart = self.msg.newChild() subpart.addHeader(u"content-type", u"text/html") attachment = self.msg.newChild() attachment.addHeader(u"content-type", u"image/png") attachment.addHeader(u"content-disposition", u'attachment; filename="foo.png"') self.parent._addToStore( self.store, Message(store=self.store), FilePath(self.dbdir).child("files").child("msg")) self.wrapper = MessageWrapperForPart(self.msg, Time()) self.assertEqual(self.wrapper.recipient, u'<No Recipient>') self.assertEqual(self.wrapper.subject, u'<No Subject>') def test_wrapperWalkAttachments(self): """ Test that walkAttachments on the message/rfc822 part returns the same thing as the wrapper's walkAttachments. """ self.createMIMEStructure() self.assertEqual([m.part for m in self.wrapper.walkAttachments()], [m.part for m in self.msg.walkAttachments()]) def test_wrapperWalkMessage(self): """ Test that walkMessage on the message/rfc822 part returns the same thing as the wrapper's walkMessage. """ self.createMIMEStructure() self.assertEqual( [m.part for m in self.wrapper.walkMessage('text/html')], [m.part for m in self.msg.walkMessage('text/html')]) def test_actions(self): """ Ensure that no action buttons get rendered. """ self.createMIMEStructure() self.assertEqual(self.wrapper.getActions(), []) def test_noSender(self): """ Test that a message with no sender headers gets handled properly. """ self.msg.addHeader(u"to", u"*****@*****.**") self.msg.addHeader(u"date", u"Fri, 13 Feb 2004 13:43:48 +0100") self.msg.addHeader(u"content-type", u"multipart/mixed") self.msg.addHeader(u"subject", u"Awesome Email") self.wrapper = MessageWrapperForPart(self.msg, Time()) self.assertEqual(self.wrapper.sender, u'') self.assertEqual(self.wrapper.senderDisplay, u'')
class PartWrapperTestCase(TestCase): """ Tests for L{xquotient.exmess.MessageWrapperForPart}. """ def setUp(self): """ Create a store and a MIME message with a message/rfc822 attachment. """ self.dbdir = self.mktemp() self.store = Store(dbdir=self.dbdir) partCounter = itertools.count().next self.parent = Part(_partCounter=partCounter) msgContainer = self.parent.newChild() msgContainer.addHeader(u"content-type", u"message/rfc822") msgContainer.addHeader(u"content-disposition", u"inline") self.msg = msgContainer.newChild() def createMIMEStructure(self): """ Insert some contents into the attached message. """ self.msg.addHeader(u"from", u"*****@*****.**") self.msg.addHeader(u"to", u"*****@*****.**") self.msg.addHeader(u"date", u"Fri, 13 Feb 2004 13:43:48 +0100") self.msg.addHeader(u"content-type", u"multipart/mixed") self.msg.addHeader(u"subject", u"Awesome Email") subpart = self.msg.newChild() subpart.addHeader(u"content-type", u"text/html") attachment = self.msg.newChild() attachment.addHeader(u"content-type", u"image/png") attachment.addHeader(u"content-disposition", u'attachment; filename="foo.png"') self.parent._addToStore(self.store, Message(store=self.store), FilePath(self.dbdir).child("files").child("msg")) self.wrapper = MessageWrapperForPart(self.msg, Time()) def test_wrapperAttributes(self): """ Test that wrapper attributes are sufficiently like Message's. """ self.createMIMEStructure() self.assertEqual(self.wrapper.impl, self.msg) self.assertEqual(self.wrapper.recipient, u'*****@*****.**') self.assertEqual(self.wrapper.sender, u'*****@*****.**') self.assertEqual(self.wrapper.subject, u'Awesome Email') def test_moreWrapperAttributes(self): """ Test that wrapper attributes are sufficiently like Message's when certain headers aren't present. """ self.msg.addHeader(u"from", u"*****@*****.**") self.msg.addHeader(u"date", u"Fri, 13 Feb 2004 13:43:48 +0100") self.msg.addHeader(u"content-type", u"multipart/mixed") subpart = self.msg.newChild() subpart.addHeader(u"content-type", u"text/html") attachment = self.msg.newChild() attachment.addHeader(u"content-type", u"image/png") attachment.addHeader(u"content-disposition", u'attachment; filename="foo.png"') self.parent._addToStore(self.store, Message(store=self.store), FilePath(self.dbdir).child("files").child("msg")) self.wrapper = MessageWrapperForPart(self.msg, Time()) self.assertEqual(self.wrapper.recipient, u'<No Recipient>') self.assertEqual(self.wrapper.subject, u'<No Subject>') def test_wrapperWalkAttachments(self): """ Test that walkAttachments on the message/rfc822 part returns the same thing as the wrapper's walkAttachments. """ self.createMIMEStructure() self.assertEqual([m.part for m in self.wrapper.walkAttachments()], [m.part for m in self.msg.walkAttachments()]) def test_wrapperWalkMessage(self): """ Test that walkMessage on the message/rfc822 part returns the same thing as the wrapper's walkMessage. """ self.createMIMEStructure() self.assertEqual([m.part for m in self.wrapper.walkMessage('text/html')], [m.part for m in self.msg.walkMessage('text/html')]) def test_actions(self): """ Ensure that no action buttons get rendered. """ self.createMIMEStructure() self.assertEqual(self.wrapper.getActions(), []) def test_noSender(self): """ Test that a message with no sender headers gets handled properly. """ self.msg.addHeader(u"to", u"*****@*****.**") self.msg.addHeader(u"date", u"Fri, 13 Feb 2004 13:43:48 +0100") self.msg.addHeader(u"content-type", u"multipart/mixed") self.msg.addHeader(u"subject", u"Awesome Email") self.wrapper = MessageWrapperForPart(self.msg, Time()) self.assertEqual(self.wrapper.sender, u'') self.assertEqual(self.wrapper.senderDisplay, u'')