[CalendarServer-changes] [7895] 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:39:14 PDT 2011
Revision: 7895
http://trac.macosforge.org/projects/calendarserver/changeset/7895
Author: glyph at apple.com
Date: 2011-08-11 21:39:14 -0700 (Thu, 11 Aug 2011)
Log Message:
-----------
Failing test for StringFormatTemplateLoader
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:39:02 UTC (rev 7894)
+++ CalendarServer/branches/users/glyph/imip-and-admin-html/twistedcaldav/test/test_mail.py 2011-08-12 04:39:14 UTC (rev 7895)
@@ -14,10 +14,14 @@
# limitations under the License.
##
+
+from cStringIO import StringIO
import datetime
import email
from twisted.internet.defer import inlineCallbacks
+
+from twisted.web.template import Element, renderer, flattenString
from twisted.python.modules import getModule
from twisted.python.filepath import FilePath
@@ -28,6 +32,7 @@
from twistedcaldav.scheduling.itip import iTIPRequestStatus
from twistedcaldav.mail import MailHandler
+from twistedcaldav.mail import StringFormatTemplateLoader
from twistedcaldav.mail import MailGatewayTokensDatabase
from twistedcaldav.directory.directory import DirectoryRecord
@@ -556,7 +561,30 @@
self.assertIn(expectedHTML, htmlPart)
+ def test_stringFormatTemplateLoader(self):
+ """
+ L{StringFormatTemplateLoader.load} will convert a template with
+ C{%(x)s}-format slots by converting it to a template with C{<t:slot
+ name="x" />} slots, and a renderer on the document element named
+ according to the constructor argument.
+ """
+ class StubElement(Element):
+ loader = StringFormatTemplateLoader(
+ StringIO("<test><alpha>%(slot1)s</alpha>%(other)s</test>"),
+ "testRenderHere"
+ )
+ @renderer
+ def testRenderHere(self, request, tag):
+ return tag.fillSlots(slot1="hello",
+ other="world")
+ result = []
+ flattenString(None, StubElement()).addCallback(result.append)
+ self.assertEquals(result,
+ ["<test><alpha>hello</alpha>world</test>"])
+
+
+
def partByType(message, contentType):
"""
Retrieve a MIME part from an L{email.message.Message} based on a content
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110811/ee114305/attachment-0001.html>
More information about the calendarserver-changes
mailing list