[CalendarServer-changes] [7879] CalendarServer/branches/users/glyph/imip-and-admin-html/ twistedcaldav/test/test_mail.py
source_changes at macosforge.org
source_changes at macosforge.org
Thu Aug 11 21:36:13 PDT 2011
Revision: 7879
http://trac.macosforge.org/projects/calendarserver/changeset/7879
Author: glyph at apple.com
Date: 2011-08-11 21:36:12 -0700 (Thu, 11 Aug 2011)
Log Message:
-----------
failing test for bad quoting of description
Modified Paths:
--------------
CalendarServer/branches/users/glyph/imip-and-admin-html/twistedcaldav/test/test_mail.py
Modified: CalendarServer/branches/users/glyph/imip-and-admin-html/twistedcaldav/test/test_mail.py
===================================================================
--- CalendarServer/branches/users/glyph/imip-and-admin-html/twistedcaldav/test/test_mail.py 2011-08-12 04:36:02 UTC (rev 7878)
+++ CalendarServer/branches/users/glyph/imip-and-admin-html/twistedcaldav/test/test_mail.py 2011-08-12 04:36:12 UTC (rev 7879)
@@ -486,10 +486,9 @@
self.assertEquals(actualReplyTo, actualFrom)
- def test_generateEmail(self):
+ def generateSampleEmail(self):
"""
- L{MailHandler.generateEmail} generates a MIME-formatted email with a
- text/plain part, a text/html part, and a text/calendar part.
+ Invoke L{MailHandler.generateEmail} and parse the result.
"""
calendar = Component.fromString(initialInviteText)
msgID, msgTxt = self.handler.generateEmail(
@@ -504,6 +503,15 @@
toAddress="user03 at localhost",
)
message = email.message_from_string(msgTxt)
+ return msgID, message
+
+
+ def test_generateEmail(self):
+ """
+ L{MailHandler.generateEmail} generates a MIME-formatted email with a
+ text/plain part, a text/html part, and a text/calendar part.
+ """
+ msgID, message = self.generateSampleEmail()
self.assertEquals(message['Message-ID'], msgID)
expectedTypes = set(["text/plain", "text/html", "text/calendar"])
actualTypes = set([
@@ -513,7 +521,21 @@
self.assertEquals(actualTypes, expectedTypes)
+ def test_emailQuoting(self):
+ """
+ L{MailHandler.generateEmail} will HTML-quote all relevant fields in the
+ HTML part, but not the text/plain part.
+ """
+ msgID, message = self.generateSampleEmail()
+ htmlPart = partByType(message, "text/html").get_payload(decode=True)
+ plainPart = partByType(message, "text/plain").get_payload(decode=True)
+ expectedPlain = 'awesome description with "<" and "&"'
+ expectedHTML = expectedPlain.replace("&", "&").replace("<", "<")
+ self.assertIn(expectedPlain, plainPart)
+ self.assertIn(expectedHTML, htmlPart)
+
+
def partByType(message, contentType):
"""
Retrieve a MIME part from an L{email.message.Message} based on a content
@@ -532,6 +554,7 @@
TestCase.setUp(self)
self.db = MailGatewayTokensDatabase(":memory:")
+
def test_tokens(self):
self.assertEquals(self.db.lookupByToken("xyzzy"), None)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110811/05bc3a97/attachment-0001.html>
More information about the calendarserver-changes
mailing list