1
##############################################################################
3
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
6
# This software is subject to the provisions of the Zope Public License,
7
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
8
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
9
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
11
# FOR A PARTICULAR PURPOSE
13
##############################################################################
14
"""Test ZPT Page Evaluation
16
$Id: test_zptpageeval.py 95489 2009-01-29 18:38:14Z faassen $
18
from unittest import TestCase, main, makeSuite
19
from zope.testing.cleanup import CleanUp # Base class w registry cleanup
20
from zope.container.contained import contained
21
from zope.app.zptpage.browser.zptpage import ZPTPageEval
23
class Test(CleanUp, TestCase):
25
def testTemplateRendering(self):
27
class Template(object):
28
def render(self, request, **kw):
29
self.called = request, kw
32
content_type = 'text/x-test'
38
class Response(object):
42
def setBase(self, base):
45
def setHeader(self, name, value):
46
setattr(self, name, value)
48
class Request(object):
52
URL = ['http://localhost', 'http://localhost/pt']
55
template = contained(Template(), folder)
58
# Do manually, since directive adds BrowserView as base class
59
view.context = template
60
view.request = request
61
self.assertEqual(view.index(), 42)
62
self.assertEqual(template.called, (request, {}))
63
self.assertEqual(getattr(request.response, 'content-type'),
67
return makeSuite(Test)
69
if __name__=='__main__':
70
main(defaultTest='test_suite')