[Zope3-checkins] CVS: Zope3/lib/python/Zope/Publisher/Browser/tests - testBrowserRequest.py:1.9
Florent Guillaume
fg@nuxeo.com
Thu, 5 Dec 2002 04:42:36 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/Publisher/Browser/tests
In directory cvs.zope.org:/tmp/cvs-serv30406/lib/python/Zope/Publisher/Browser/tests
Modified Files:
testBrowserRequest.py
Log Message:
Fixed bug in uri parsing, where the query string was unquoted twice
(once by RequestParser and once by FieldStorage).
Added tests to check that unquoting is done correctly.
=== Zope3/lib/python/Zope/Publisher/Browser/tests/testBrowserRequest.py 1.8 => 1.9 ===
--- Zope3/lib/python/Zope/Publisher/Browser/tests/testBrowserRequest.py:1.8 Tue Jun 18 10:47:06 2002
+++ Zope3/lib/python/Zope/Publisher/Browser/tests/testBrowserRequest.py Thu Dec 5 04:42:05 2002
@@ -22,6 +22,7 @@
from Zope.Publisher.HTTP.HTTPCharsets import HTTPCharsets
from Zope.Publisher.Browser.BrowserRequest import BrowserRequest
from Zope.Publisher.Browser.BrowserResponse import BrowserResponse
+from Zope.Publisher.Exceptions import NotFound
from Zope.Publisher.DefaultPublication import DefaultPublication
from Zope.Publisher.Browser.IBrowserPresentation import IBrowserPresentation
@@ -72,6 +73,11 @@
def __call__(self, a, b):
return "%s, %s" % (`a`, `b`)
+ class Item3:
+ " "
+ def __call__(self, *args):
+ return "..."
+
class View:
" "
def browserDefault(self, request):
@@ -93,6 +99,7 @@
self.app.folder = Folder()
self.app.folder.item = Item()
self.app.folder.item2 = Item2()
+ self.app.folder.item3 = Item3()
def _createRequest(self, extra_env={}, body="", outstream=None):
env = self._testEnv.copy()
@@ -180,10 +187,19 @@
publish(request)
self.assertEqual(response.getBase(),
'http://foobar.com/folder/item2/view/index')
-
+
+ def testBadPath(self):
+ extra = {'PATH_INFO': '/folder/nothere/'}
+ request = self._createRequest(extra)
+ self.assertRaises(NotFound, publish, request)
+
+ def testBadPath2(self):
+ extra = {'PATH_INFO': '/folder%2Fitem2/'}
+ request = self._createRequest(extra)
+ self.assertRaises(NotFound, publish, request)
+
def testForm(self):
request = self._createRequest()
- response = request.response
publish(request)
self.assertEqual(request.form,
{u'a':u'5', u'b':6})
@@ -192,14 +208,12 @@
#extra = {'QUERY_STRING':'x.a:list:record=5&x.a:list:record=6'}
extra = {'QUERY_STRING':'a:list=5&a:list=6&b=1'}
request = self._createRequest(extra)
- response = request.response
publish(request)
self.assertEqual(request.form, {u'a':[u'5',u'6'], u'b':u'1'})
def testFormListRecordTypes(self):
extra = {'QUERY_STRING':'a.x:list:record=5&a.x:list:record=6&b=1'}
request = self._createRequest(extra)
- response = request.response
publish(request)
keys = request.form.keys()
keys.sort()
@@ -211,23 +225,34 @@
def testFormListTypes2(self):
extra = {'QUERY_STRING':'a=5&a=6&b=1'}
request = self._createRequest(extra)
- response = request.response
publish(request)
self.assertEqual(request.form, {'a':[u'5',u'6'], 'b':u'1'})
def testFormDefaults(self):
extra = {'QUERY_STRING':'a:default=10&a=6&b=1'}
request = self._createRequest(extra)
- response = request.response
publish(request)
self.assertEqual(request.form, {u'a':u'6', u'b':u'1'})
def testFormDefaults2(self):
extra = {'QUERY_STRING':'a:default=10&b=1'}
request = self._createRequest(extra)
- response = request.response
publish(request)
self.assertEqual(request.form, {u'a':u'10', u'b':u'1'})
+
+ def testFormFieldName(self):
+ extra = {'QUERY_STRING':'c+%2B%2F%3D%26c%3Aint=6',
+ 'PATH_INFO': '/folder/item3/'}
+ request = self._createRequest(extra)
+ publish(request)
+ self.assertEqual(request.form, {u'c +/=&c': 6})
+
+ def testFormFieldValue(self):
+ extra = {'QUERY_STRING':'a=b+%2B%2F%3D%26b%3Aint',
+ 'PATH_INFO': '/folder/item3/'}
+ request = self._createRequest(extra)
+ publish(request)
+ self.assertEqual(request.form, {u'a':u'b +/=&b:int'})
def test_suite():