Skip to content

Commit

Permalink
- Resolved all my outstanding XXX comments.
Browse files Browse the repository at this point in the history
- Wrote all final deprecation warnings.
- Made sure that all tests pass without deprecation warnings being raised.

The day of days is nearing! :-)
  • Loading branch information
strichter committed Feb 14, 2005
1 parent 1333c8e commit ae2c846
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 2 deletions.
3 changes: 1 addition & 2 deletions simpleviewclass.py
Expand Up @@ -37,14 +37,13 @@ def publishTraverse(self, request, name):

raise NotFound(self, name, request)

# XXX: we need some unittests for this !!!
def __getitem__(self, name):
return self.index.macros[name]

def __call__(self, *args, **kw):
return self.index(*args, **kw)

# XXX: Test new name argument

def SimpleViewClass(src, offering=None, used_for=None, bases=(), name=u''):
if offering is None:
offering = sys._getframe(1).f_globals
Expand Down
73 changes: 73 additions & 0 deletions tests/test_simpleviewclass.py
@@ -0,0 +1,73 @@
##############################################################################
#
# 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.1 (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.
#
##############################################################################
"""Simple View Class Tests
$Id$
"""
import unittest

from zope.app.pagetemplate.simpleviewclass import SimpleViewClass
from zope.app.pagetemplate.tests.simpletestview import SimpleTestView
from zope.publisher.browser import TestRequest

class data(object): pass

class SimpleViewTestCase(unittest.TestCase):

def test_simple(self):
ob = data()
request = TestRequest()
view = SimpleTestView(ob, request)
macro = view['test']
out = view()
self.assertEqual(out,
'<html>\n'
' <body>\n'
' <p>hello world</p>\n'
' </body>\n</html>\n')

def test_name(self):
View = SimpleViewClass('testsimpleviewclass.pt', name='test.html')
view = View(None, None)
self.assertEqual(view.__name__, 'test.html')

def test_getitem(self):
View = SimpleViewClass('testsimpleviewclass.pt', name='test.html')
view = View(None, None)
self.assert_(view['test'] is not None)
self.assertRaises(KeyError, view.__getitem__, 'foo')

def test_WBases(self):
class C(object): pass

SimpleTestView = SimpleViewClass('testsimpleviewclass.pt', bases=(C, ))

self.failUnless(issubclass(SimpleTestView, C))

ob = data()
request = TestRequest()
view = SimpleTestView(ob, request)
macro = view['test']
out = view()
self.assertEqual(out,
'<html>\n'
' <body>\n'
' <p>hello world</p>\n'
' </body>\n</html>\n')

def test_suite():
return unittest.makeSuite(SimpleViewTestCase)

if __name__=='__main__':
unittest.TextTestRunner().run(test_suite())

0 comments on commit ae2c846

Please sign in to comment.