[Zope3-checkins]
SVN: Zope3/branches/stephan_and_jim-response-refactor/src/zope/
Fixed test recorder test.
Stephan Richter
srichter at cosmos.phy.tufts.edu
Wed Sep 7 09:03:22 EDT 2005
Log message for revision 38338:
Fixed test recorder test.
Changed:
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/recorder/__init__.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/recorder/tests.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/server/http/wsgihttpserver.py
-=-
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/recorder/__init__.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/recorder/__init__.py 2005-09-07 08:44:38 UTC (rev 38337)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/recorder/__init__.py 2005-09-07 13:03:22 UTC (rev 38338)
@@ -99,7 +99,7 @@
Wraps PublisherHTTPServer.executeRequest().
"""
- PublisherHTTPServer.executeRequest(self, task)
+ super(RecordingHTTPServer, self).executeRequest(task)
# PublisherHTTPServer either committed or aborted a transaction,
# so we need a new one.
# TODO: Actually, we only need a transaction if we use
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/recorder/tests.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/recorder/tests.py 2005-09-07 08:44:38 UTC (rev 38337)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/recorder/tests.py 2005-09-07 13:03:22 UTC (rev 38338)
@@ -27,36 +27,6 @@
from zope.app.publisher.browser import BrowserView
-def doctest_RecordingHTTPServer():
- r"""Unit tests for RecordingHTTPServer.
-
- We will use stubs instead of real channel and request parser objects, to
- keep the test fixture small.
-
- >>> from zope.app.recorder import RecordingHTTPTask
- >>> channel = ChannelStub()
- >>> request_data = RequestDataStub()
- >>> task = RecordingHTTPTask(channel, request_data)
-
- RecordingHTTPTask is a thin wrapper around HTTPTask. It records all data
- written through task.write, plus the response header, of course.
-
- >>> task.write('request body\n')
- >>> task.write('goes in here')
-
- We need to strip CR characters, as they confuse doctest.
-
- >>> print task.getRawResponse().replace('\r', '')
- HTTP/1.1 200 Ok
- Connection: close
- Server: Stub Server
- <BLANKLINE>
- request body
- goes in here
-
- """
-
-
def doctest_RecordingHTTPRequestParser():
r"""Unit tests for RecordingHTTPRequestParser.
@@ -99,10 +69,23 @@
Further, to keep things simple, we will override the constructor and
prevent it from listening on sockets.
+ >>> def application(environ, start_response):
+ ... return ()
+
+ >>> from zope.publisher.publish import publish
>>> from zope.app.recorder import RecordingHTTPServer
>>> class RecordingHTTPServerForTests(RecordingHTTPServer):
... def __init__(self):
- ... self.request_factory = RecorderRequest
+ ... pass
+ ...
+ ... def application(self, environ, start_response):
+ ... request = RecorderRequest(environ['wsgi.input'], environ)
+ ... response = request.response
+ ... publish(request)
+ ... start_response(response.getStatusString(),
+ ... response.getHeaders())
+ ... return ()
+
>>> server = RecordingHTTPServerForTests()
We will need a request parser
@@ -140,13 +123,13 @@
'/'
>>> print rq.response_string.replace('\r', '')
HTTP/1.1 599 No status set
- Content-Length: 0
- X-Powered-By: Zope (www.zope.org), Python (www.python.org)
+ Connection: close
Server: Stub Server
+ X-Powered-By: Zope (www.zope.org), Python (www.python.org)
<BLANKLINE>
<BLANKLINE>
>>> rq.status
- 599
+ '599'
>>> rq.reason
'No status set'
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/server/http/wsgihttpserver.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/server/http/wsgihttpserver.py 2005-09-07 08:44:38 UTC (rev 38337)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/server/http/wsgihttpserver.py 2005-09-07 13:03:22 UTC (rev 38338)
@@ -30,6 +30,8 @@
class WSGIHTTPServer(HTTPServer):
"""Zope Publisher-specific WSGI-compliant HTTP Server"""
+ application = None
+
def __init__(self, application, sub_protocol=None, *args, **kw):
if sys.platform[:3] == "win" and args[0] == 'localhost':
More information about the Zope3-Checkins
mailing list