[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/ Merged from 3.2
branch:
Jim Fulton
jim at zope.com
Sat Dec 24 11:57:06 EST 2005
Log message for revision 41033:
Merged from 3.2 branch:
------------------------------------------------------------------------
r41003 | jim | 2005-12-23 16:01:18 -0500 (Fri, 23 Dec 2005) | 3 lines
Fixed tests that weren't calling request constructors properly.
The first positional argument is the input stream.
Changed:
U Zope3/trunk/src/zope/app/authentication/httpplugins.py
U Zope3/trunk/src/zope/app/exception/browser/tests/test_unauthorized.py
U Zope3/trunk/src/zope/app/http/exception/tests/test_unauthorized.py
U Zope3/trunk/src/zope/app/publication/tests/test_browserpublication.py
U Zope3/trunk/src/zope/app/session/http.py
U Zope3/trunk/src/zope/app/session/session.py
U Zope3/trunk/src/zope/app/session/tests.py
-=-
Modified: Zope3/trunk/src/zope/app/authentication/httpplugins.py
===================================================================
--- Zope3/trunk/src/zope/app/authentication/httpplugins.py 2005-12-24 16:55:56 UTC (rev 41032)
+++ Zope3/trunk/src/zope/app/authentication/httpplugins.py 2005-12-24 16:57:05 UTC (rev 41033)
@@ -69,7 +69,7 @@
Also, this plugin can *only* handle basic authentication.
- >>> request = TestRequest({'HTTP_AUTHORIZATION': 'foo bar'})
+ >>> request = TestRequest(environ={'HTTP_AUTHORIZATION': 'foo bar'})
>>> print plugin.extractCredentials(TestRequest())
None
Modified: Zope3/trunk/src/zope/app/exception/browser/tests/test_unauthorized.py
===================================================================
--- Zope3/trunk/src/zope/app/exception/browser/tests/test_unauthorized.py 2005-12-24 16:55:56 UTC (rev 41032)
+++ Zope3/trunk/src/zope/app/exception/browser/tests/test_unauthorized.py 2005-12-24 16:57:05 UTC (rev 41033)
@@ -67,7 +67,7 @@
raise exception
except:
pass
- request = TestRequest('/')
+ request = TestRequest()
request.setPrincipal(DummyPrincipal(23))
u = Unauthorized(exception, request)
u.issueChallenge()
@@ -85,7 +85,7 @@
raise exception
except:
pass
- request = TestRequest('/')
+ request = TestRequest()
psrc = DummyPrincipalSource()
request.setPrincipal(DummyPrincipal(23))
u = Unauthorized(exception, request)
Modified: Zope3/trunk/src/zope/app/http/exception/tests/test_unauthorized.py
===================================================================
--- Zope3/trunk/src/zope/app/http/exception/tests/test_unauthorized.py 2005-12-24 16:55:56 UTC (rev 41032)
+++ Zope3/trunk/src/zope/app/http/exception/tests/test_unauthorized.py 2005-12-24 16:57:05 UTC (rev 41033)
@@ -28,7 +28,7 @@
raise exception
except:
pass
- request = TestRequest('/')
+ request = TestRequest()
u = Unauthorized(exception, request)
# Chech that we implement the right interface
Modified: Zope3/trunk/src/zope/app/publication/tests/test_browserpublication.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/tests/test_browserpublication.py 2005-12-24 16:55:56 UTC (rev 41032)
+++ Zope3/trunk/src/zope/app/publication/tests/test_browserpublication.py 2005-12-24 16:57:05 UTC (rev 41033)
@@ -306,7 +306,7 @@
def testGetBackSamePublication(self):
factory = HTTPPublicationRequestFactory(db=None)
- args = (None, {})
+ args = (StringIO(''), {})
self.assert_(id(factory(*args).publication) ==
id(factory(*args).publication))
Modified: Zope3/trunk/src/zope/app/session/http.py
===================================================================
--- Zope3/trunk/src/zope/app/session/http.py 2005-12-24 16:55:56 UTC (rev 41032)
+++ Zope3/trunk/src/zope/app/session/http.py 2005-12-24 16:57:05 UTC (rev 41033)
@@ -15,7 +15,7 @@
$Id$
"""
-
+from cStringIO import StringIO
from persistent import Persistent
from zope.app.annotation.interfaces import IAttributeAnnotatable
from zope.app.i18n import ZopeMessageFactory as _
@@ -90,7 +90,7 @@
This creates one if necessary:
>>> from zope.publisher.http import HTTPRequest
- >>> request = HTTPRequest(None, {}, None)
+ >>> request = HTTPRequest(StringIO(''), {}, None)
>>> bim = CookieClientIdManager()
>>> id = bim.getClientId(request)
>>> id == bim.getClientId(request)
@@ -98,7 +98,7 @@
The id is retained accross requests:
- >>> request2 = HTTPRequest(None, {}, None)
+ >>> request2 = HTTPRequest(StringIO(''), {}, None)
>>> request2._cookies = dict(
... [(name, cookie['value'])
... for (name, cookie) in request.response._cookies.items()
@@ -148,7 +148,7 @@
For example:
>>> from zope.publisher.http import HTTPRequest
- >>> request = HTTPRequest(None, {}, None)
+ >>> request = HTTPRequest(StringIO(''), {}, None)
>>> bim = CookieClientIdManager()
Because no cookie has been set, we get no id:
@@ -169,7 +169,7 @@
When we set the request id, we also set a response cookie. We
can simulate getting this cookie back in a subsequent request:
- >>> request2 = HTTPRequest(None, {}, None)
+ >>> request2 = HTTPRequest(StringIO(''), {}, None)
>>> request2._cookies = dict(
... [(name, cookie['value'])
... for (name, cookie) in request.response._cookies.items()
@@ -210,7 +210,7 @@
invalid value is silently ignored:
>>> from zope.publisher.http import HTTPRequest
- >>> request = HTTPRequest(None, {}, None)
+ >>> request = HTTPRequest(StringIO(''), {}, None)
>>> bim = CookieClientIdManager()
>>> bim.getRequestId(request)
>>> bim.setRequestId(request, 'invalid id')
@@ -233,7 +233,7 @@
Expiry time of 0 means never (well - close enough)
>>> bim.cookieLifetime = 0
- >>> request = HTTPRequest(None, {}, None)
+ >>> request = HTTPRequest(StringIO(''), {}, None)
>>> bid = bim.getClientId(request)
>>> cookie = request.response.getCookie(bim.namespace)
>>> cookie['expires']
@@ -242,7 +242,7 @@
A non-zero value means to expire after than number of seconds:
>>> bim.cookieLifetime = 3600
- >>> request = HTTPRequest(None, {}, None)
+ >>> request = HTTPRequest(StringIO(''), {}, None)
>>> bid = bim.getClientId(request)
>>> cookie = request.response.getCookie(bim.namespace)
>>> import rfc822
Modified: Zope3/trunk/src/zope/app/session/session.py
===================================================================
--- Zope3/trunk/src/zope/app/session/session.py 2005-12-24 16:55:56 UTC (rev 41032)
+++ Zope3/trunk/src/zope/app/session/session.py 2005-12-24 16:57:05 UTC (rev 41033)
@@ -15,6 +15,7 @@
$Id$
"""
+from cStringIO import StringIO
import sha, time, string, random, hmac, warnings, thread, zope.interface
from UserDict import IterableUserDict
from heapq import heapify, heappop
@@ -270,7 +271,7 @@
>>> import tests
>>> request = tests.setUp(PersistentSessionDataContainer)
- >>> request2 = tests.HTTPRequest(None, {}, None)
+ >>> request2 = tests.HTTPRequest(StringIO(''), {}, None)
>>> ISession.providedBy(Session(request))
True
Modified: Zope3/trunk/src/zope/app/session/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/session/tests.py 2005-12-24 16:55:56 UTC (rev 41032)
+++ Zope3/trunk/src/zope/app/session/tests.py 2005-12-24 16:57:05 UTC (rev 41033)
@@ -15,6 +15,7 @@
$Id$
"""
+from cStringIO import StringIO
import unittest, doctest, os, os.path, sys
from zope.app import zapi
from zope.app.testing import ztapi, placelesssetup
@@ -47,7 +48,7 @@
sdc = session_data_container_class()
for product_id in ('', 'products.foo', 'products.bar', 'products.baz'):
ztapi.provideUtility(ISessionDataContainer, sdc, product_id)
- request = HTTPRequest(None, {}, None)
+ request = HTTPRequest(StringIO(), {}, None)
return request
def tearDown():
More information about the Zope3-Checkins
mailing list