[CalendarServer-changes] [7900] 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:40:09 PDT 2011


Revision: 7900
          http://trac.macosforge.org/projects/calendarserver/changeset/7900
Author:   glyph at apple.com
Date:     2011-08-11 21:40:09 -0700 (Thu, 11 Aug 2011)
Log Message:
-----------
test for tag-soup templates since we may have to handle those

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:58 UTC (rev 7899)
+++ CalendarServer/branches/users/glyph/imip-and-admin-html/twistedcaldav/test/test_mail.py	2011-08-12 04:40:09 UTC (rev 7900)
@@ -612,7 +612,33 @@
                            'inner</alpha>world</test>'])
 
 
+    def test_templateLoaderTagSoup(self):
+        """
+        L{StringFormatTemplateLoader.load} will convert a template with
+        C{%(x)s}-format slots into t:slot slots, and render a well-formed output
+        document, even if the input is malformed (i.e. missing necessary closing
+        tags).
+        """
+        class StubElement(Element):
+            loader = StringFormatTemplateLoader(
+                lambda : StringIO(
+                    '<test><alpha beta="before %(slot1)s after">inner</alpha>'
+                    '%(other)s'
+                ),
+                "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 beta="before hello after">'
+                           'inner</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/2dab118e/attachment.html>


More information about the calendarserver-changes mailing list