[Zope3-checkins] CVS: Zope3/src/zope/app/content/tests - test_zptpage.py:1.8

Sidnei da Silva sidnei@x3ng.com.br
Wed, 2 Apr 2003 13:38:21 -0500


Update of /cvs-repository/Zope3/src/zope/app/content/tests
In directory cvs.zope.org:/tmp/cvs-serv22100/tests

Modified Files:
	test_zptpage.py 
Log Message:
Enabling source view under @@source.html for ZPT pages. Were using this for Moztop.

=== Zope3/src/zope/app/content/tests/test_zptpage.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/content/tests/test_zptpage.py:1.7	Mon Feb  3 10:08:34 2003
+++ Zope3/src/zope/app/content/tests/test_zptpage.py	Wed Apr  2 13:38:21 2003
@@ -23,10 +23,13 @@
 from zope.exceptions import Forbidden
 
 import zope.app.content.zpt
-from zope.app.content.zpt import ZPTPage, SearchableText
+from zope.app.content.zpt import ZPTPage, SearchableText, ZPTSourceView
 from zope.app.interfaces.content.zpt import IZPTPage
 from zope.app.interfaces.index.text import ISearchableText
-from zope.component import getAdapter
+from zope.component import getAdapter, getView
+from zope.component.view import provideView
+from zope.publisher.interfaces.browser import IBrowserPresentation
+from zope.publisher.browser import TestRequest
 
 # Wow, this is a lot of work. :(
 from zope.app.tests.placelesssetup import PlacelessSetup
@@ -160,12 +163,32 @@
         page = zope.app.content.zpt.ZPTFactory(None)('foo', '', content)
         self.assertEqual(page.getSource(), content)
     
+class ZPTSourceTest(PlacelessSetup, unittest.TestCase):
+
+    def setUp(self):
+        PlacelessSetup.setUp(self)
+        provideView(IZPTPage, 'source.html', IBrowserPresentation, ZPTSourceView)
+
+    def testSourceView(self):
+        page = ZPTPage()
+
+        utext = u'another test\n' # The source will grow a newline if ommited
+        html = u"<html><body>%s</body></html>\n" % (utext, )
+        page.setSource(html, content_type='text/plain')
+        request = TestRequest()
+
+        view = getView(page, 'source.html', request)
+
+        self.assertEqual(str(view), html)
+        self.assertEqual(view(), html)
+
 
 def test_suite():
     return unittest.TestSuite((
         unittest.makeSuite(ZPTPageTests),
         unittest.makeSuite(SizedTests),
         unittest.makeSuite(TestFileEmulation),
+        unittest.makeSuite(ZPTSourceTest),
         ))
 
 if __name__=='__main__':