[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Content/ZPTPage/Views/Browser/tests - __init__.py:1.2 testZPTPageEval.py:1.2

Jim Fulton jim@zope.com
Mon, 10 Jun 2002 19:28:37 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Content/ZPTPage/Views/Browser/tests
In directory cvs.zope.org:/tmp/cvs-serv17445/lib/python/Zope/App/OFS/Content/ZPTPage/Views/Browser/tests

Added Files:
	__init__.py testZPTPageEval.py 
Log Message:
Merged Zope-3x-branch into newly forked Zope3 CVS Tree.


=== Zope3/lib/python/Zope/App/OFS/Content/ZPTPage/Views/Browser/tests/__init__.py 1.1 => 1.2 ===
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+# 
+##############################################################################
+"""
+
+$Id$
+"""


=== Zope3/lib/python/Zope/App/OFS/Content/ZPTPage/Views/Browser/tests/testZPTPageEval.py 1.1 => 1.2 ===
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE
+# 
+##############################################################################
+"""
+
+Revision information:
+$Id$
+"""
+
+from unittest import TestCase, TestSuite, main, makeSuite
+from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
+
+from Zope.App.OFS.Content.ZPTPage.Views.Browser.ZPTPageEval import ZPTPageEval
+from Zope.Proxy.ContextWrapper import ContextWrapper
+
+
+class Test(CleanUp, TestCase):
+
+    def test(self):
+
+        class Template:
+            def render(self, request, **kw):
+                self.called = request, kw
+                return 42
+
+            content_type = 'text/x-test'
+
+        class Folder: name='zope'
+        folder = Folder()
+        
+        class Request:
+            def getResponse(self):
+                return self
+            def setHeader(self, name, value):
+                setattr(self, name, value)
+                           
+        request = Request()
+
+        template = ContextWrapper(Template(), folder)
+
+        view = ZPTPageEval(template, None)
+        self.assertEqual(view.index(request), 42)
+        self.assertEqual(template.called, (request, {}))
+        self.assertEqual(getattr(request, 'content-type'), 'text/x-test')
+
+def test_suite():
+    return TestSuite((
+        makeSuite(Test),
+        ))
+
+if __name__=='__main__':
+    main(defaultTest='test_suite')