[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Content/DTMLPage/Views/Browser/tests - __init__.py:1.1 testDTMLPageEval.py:1.1

Stephan Richter srichter@cbu.edu
Wed, 10 Jul 2002 20:17:04 -0400


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

Added Files:
	__init__.py testDTMLPageEval.py 
Log Message:
Similar to the ZPT Page we should also have a DTML Page. Currently it does
not implement the DTML 2 proposal (no time). :(


=== Added File Zope3/lib/python/Zope/App/OFS/Content/DTMLPage/Views/Browser/tests/__init__.py ===
##############################################################################
#
# 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: __init__.py,v 1.1 2002/07/11 00:17:02 srichter Exp $
"""


=== Added File Zope3/lib/python/Zope/App/OFS/Content/DTMLPage/Views/Browser/tests/testDTMLPageEval.py ===
##############################################################################
#
# 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: testDTMLPageEval.py,v 1.1 2002/07/11 00:17:02 srichter Exp $
"""

from unittest import TestCase, TestSuite, main, makeSuite
from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup

from Zope.App.OFS.Content.DTMLPage.Views.Browser.DTMLPageEval import \
     DTMLPageEval
from Zope.Proxy.ContextWrapper import ContextWrapper


class Test(CleanUp, TestCase):

    def test(self):

        class Template:
            def render(self, request, **kw):
                self.called = request, kw
                request.response.setHeader('content-type', self.content_type)
                return 42

            content_type = 'text/x-test'

        class Folder: name='zope'
        folder = Folder()
        
        class Request(object):

            def _getResponse(self):
                return self

            response = property(_getResponse)
            
            def setHeader(self, name, value):
                setattr(self, name, value)
                           
        request = Request()

        template = ContextWrapper(Template(), folder)

        view = DTMLPageEval(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')