[Zope-Checkins] CVS: Zope3/lib/python/Zope/Publisher/Browser/tests - testBrowserRequest.py:1.4
Steve Alexander
steve@cat-box.net
Tue, 11 Jun 2002 11:53:56 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/Publisher/Browser/tests
In directory cvs.zope.org:/tmp/cvs-serv23763/lib/python/Zope/Publisher/Browser/tests
Modified Files:
testBrowserRequest.py
Log Message:
various reformatting.
fixed bugs with :list in BrowserRequest
made various tests use publish(request, handle_errors=0)
increased test coverage of testBrowserRequest
=== Zope3/lib/python/Zope/Publisher/Browser/tests/testBrowserRequest.py 1.3 => 1.4 ===
from Zope.Publisher.Browser.BrowserResponse import BrowserResponse
-from Zope.Publisher.Publish import publish
from Zope.Publisher.DefaultPublication import DefaultPublication
from Zope.Publisher.Browser.IBrowserPresentation import IBrowserPresentation
@@ -24,6 +23,10 @@
from Zope.Publisher.HTTP.tests.testHTTP import HTTPTests
+from Zope.Publisher.Publish import publish as publish_
+def publish(request):
+ publish_(request, handle_errors=0)
+
class Publication(DefaultPublication):
def getDefaultTraversal(self, request, ob):
@@ -95,7 +98,6 @@
return request
def testTraversalToItem(self):
- return
res = self._publisherResults()
self.failUnlessEqual(
res,
@@ -132,7 +134,7 @@
def testDefaultPOST(self):
extra = {'PATH_INFO': '/folder/item2', "REQUEST_METHOD": "POST"}
- request = self._createRequest(extra)
+ request = self._createRequest(extra, body='a=5&b:int=6')
response = request.getResponse()
publish(request)
self.assertEqual(response.getBase(),
@@ -174,6 +176,48 @@
publish(request)
self.assertEqual(request.form,
{'a':'5', 'b':6})
+
+ def testFormListTypes(self):
+ #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.getResponse()
+ publish(request)
+ self.assertEqual(request.form, {'a':['5','6'], 'b':'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.getResponse()
+ publish(request)
+ keys = request.form.keys()
+ keys.sort()
+ self.assertEqual(keys, ['a','b'])
+ self.assertEqual(request.form['b'], '1')
+ self.assertEqual(request.form['a'].keys(), ['x'])
+ self.assertEqual(request.form['a']['x'], ['5','6'])
+
+ def testFormListTypes2(self):
+ extra = {'QUERY_STRING':'a=5&a=6&b=1'}
+ request = self._createRequest(extra)
+ response = request.getResponse()
+ publish(request)
+ self.assertEqual(request.form, {'a':['5','6'], 'b':'1'})
+
+ def testFormDefaults(self):
+ extra = {'QUERY_STRING':'a:default=10&a=6&b=1'}
+ request = self._createRequest(extra)
+ response = request.getResponse()
+ publish(request)
+ self.assertEqual(request.form, {'a':'6', 'b':'1'})
+
+ def testFormDefaults2(self):
+ extra = {'QUERY_STRING':'a:default=10&b=1'}
+ request = self._createRequest(extra)
+ response = request.getResponse()
+ publish(request)
+ self.assertEqual(request.form, {'a':'10', 'b':'1'})
+
def test_suite():
loader = unittest.TestLoader()