[Zope3-checkins] CVS: Zope3/src/zope/app/services/tests - test_zpt.py:1.3
Jim Fulton
jim@zope.com
Wed, 2 Apr 2003 14:48:21 -0500
Update of /cvs-repository/Zope3/src/zope/app/services/tests
In directory cvs.zope.org:/tmp/cvs-serv32547/tests
Modified Files:
test_zpt.py
Log Message:
Template usage wasn't handled correctly. This caused page rendering
to fail whan no usage was specified.
=== Zope3/src/zope/app/services/tests/test_zpt.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/services/tests/test_zpt.py:1.2 Tue Feb 11 10:59:58 2003
+++ Zope3/src/zope/app/services/tests/test_zpt.py Wed Apr 2 14:48:21 2003
@@ -17,6 +17,7 @@
from unittest import TestCase, TestSuite, main, makeSuite
import zope.app.services.zpt
+from zope.publisher.browser import BrowserView, TestRequest
class Test(TestCase):
@@ -44,6 +45,38 @@
source = '<p>Test content</p>'
template = factory('foo', 'text/html', source)
self.assertEqual(template.source, source)
+
+ def test_usage(self):
+ template = zope.app.services.zpt.ZPTTemplate()
+ template.source = ('usage: <span tal:replace="usage" />\n'
+ 'options: <span tal:replace="options" />'
+ )
+ view = BrowserView(42, TestRequest())
+
+ self.assertEqual(template.render(view),
+ 'usage: \n'
+ 'options: {}\n'
+ )
+
+ self.assertEqual(template.render(view, template_usage=u"spam"),
+ "usage: spam\n"
+ "options: {'template_usage': u'spam'}\n"
+ )
+
+ template.usage = u'eggs'
+
+ self.assertEqual(template.render(view, template_usage=u"spam"),
+ "usage: spam\n"
+ "options: {'template_usage': u'spam'}\n"
+ )
+
+ self.assertEqual(template.render(view),
+ "usage: eggs\n"
+ "options: {'template_usage': u'eggs'}\n"
+ )
+
+
+
def test_suite():
return TestSuite((