[Zope-Checkins] CVS: Packages/ZPublisher/tests -
testBaseRequest.py:1.1.6.4
Stefan H. Holek
stefan at epy.co.at
Sun Feb 19 07:11:11 EST 2006
Update of /cvs-repository/Packages/ZPublisher/tests
In directory cvs.zope.org:/tmp/cvs-serv20926/lib/python/ZPublisher/tests
Modified Files:
Tag: Zope-2_7-branch
testBaseRequest.py
Log Message:
ZPublisher.BaseRequest: The publisher would happily publish attributes
of type 'bool' and 'complex'.
=== Packages/ZPublisher/tests/testBaseRequest.py 1.1.6.3 => 1.1.6.4 ===
--- Packages/ZPublisher/tests/testBaseRequest.py:1.1.6.3 Wed Nov 3 12:46:34 2004
+++ Packages/ZPublisher/tests/testBaseRequest.py Sun Feb 19 07:11:11 2006
@@ -21,6 +21,22 @@
"""
return 'view content'
+ def noview(self):
+ # Attribute without docstring.
+ return 'unpublishable'
+
+
+class DummyObjectWithoutDocstring(Implicit):
+ ""
+
+ def view(self):
+ """Attribute with docstring."""
+ return 'view content'
+
+ def noview(self):
+ # Attribute without docstring.
+ return 'unpublishable'
+
class DummyObjectWithDefault(DummyObjectBasic):
""" Dummy class with docstring.
@@ -79,6 +95,7 @@
return getattr(self, name)
raise AttributeError, name
+
class TestBaseRequest(TestCase):
def setUp(self):
@@ -91,6 +108,11 @@
self.f1._setObject('objWithBD', DummyObjectWithBD() )
self.f1._setObject('objWithBBT', DummyObjectWithBBT() )
self.f1._setObject('objWithBDBBT', DummyObjectWithBDBBT() )
+ self.f1._setObject('objWithoutDocstring', DummyObjectWithoutDocstring() )
+ self.f1.simpleString = 'foo'
+ self.f1.simpleList = []
+ self.f1.simpleBoolean = True
+ self.f1.simpleComplex = complex(1)
def makeBaseRequest(self):
response = HTTPResponse()
@@ -193,6 +215,40 @@
r.traverse('/')
self.assertEqual(r.URL, '/index_html')
self.assertEqual(r.response.base, '')
+
+ def test_traverse_attribute_with_docstring(self):
+ r = self.makeBaseRequest()
+ r.traverse('folder/objBasic/view')
+ self.assertEqual(r.URL, '/folder/objBasic/view')
+ self.assertEqual(r.response.base, '')
+
+ def test_traverse_attribute_without_docstring(self):
+ from ZPublisher import NotFound
+ r = self.makeBaseRequest()
+ self.assertRaises(NotFound, r.traverse, 'folder/objBasic/noview')
+
+ def test_traverse_class_without_docstring(self):
+ from ZPublisher import NotFound
+ r = self.makeBaseRequest()
+ self.assertRaises(NotFound, r.traverse, 'folder/objWithoutDocstring')
+
+ def test_traverse_attribute_of_class_without_docstring(self):
+ from ZPublisher import NotFound
+ r = self.makeBaseRequest()
+ self.assertRaises(NotFound, r.traverse, 'folder/objWithoutDocstring/view')
+
+ def test_traverse_attribute_and_class_without_docstring(self):
+ from ZPublisher import NotFound
+ r = self.makeBaseRequest()
+ self.assertRaises(NotFound, r.traverse, 'folder/objWithoutDocstring/noview')
+
+ def test_traverse_simple_type(self):
+ from ZPublisher import NotFound
+ r = self.makeBaseRequest()
+ self.assertRaises(NotFound, r.traverse, 'folder/simpleString')
+ self.assertRaises(NotFound, r.traverse, 'folder/simpleList')
+ self.assertRaises(NotFound, r.traverse, 'folder/simpleBoolean')
+ self.assertRaises(NotFound, r.traverse, 'folder/simpleComplex')
def test_suite():
More information about the Zope-Checkins
mailing list