diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-01-15 00:20:04 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-01-15 00:20:04 +0000 |
| commit | c8cf2256655ee4b34ec501325b9016608b5cce5f (patch) | |
| tree | 065c104d852d70389ce328813e2e8ea33e9885ce /repoze/bfg/tests/test_wsgi.py | |
| parent | ec54985a5c27846a7e9444c22bcf46ae7e868b66 (diff) | |
| download | pyramid-c8cf2256655ee4b34ec501325b9016608b5cce5f.tar.gz pyramid-c8cf2256655ee4b34ec501325b9016608b5cce5f.tar.bz2 pyramid-c8cf2256655ee4b34ec501325b9016608b5cce5f.zip | |
- Instead of invariably using ``webob.Request`` as the "request
factory" (e.g. in the ``Router`` class) and ``webob.Response`` and
the "response factory" (e.g. in ``render_template_to_response``),
allow both to be overridden via a ZCML utility hook. See the "Using
ZCML Hooks" chapter of the documentation for more information.
Diffstat (limited to 'repoze/bfg/tests/test_wsgi.py')
| -rw-r--r-- | repoze/bfg/tests/test_wsgi.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/repoze/bfg/tests/test_wsgi.py b/repoze/bfg/tests/test_wsgi.py index 4c36850b6..ac02ec49f 100644 --- a/repoze/bfg/tests/test_wsgi.py +++ b/repoze/bfg/tests/test_wsgi.py @@ -1,6 +1,13 @@ import unittest +from zope.testing.cleanup import cleanUp class WSGIAppTests(unittest.TestCase): + def setUp(self): + cleanUp() + + def tearDown(self): + cleanUp() + def test_decorator(self): body = 'Unauthorized' headerlist = [ ('Content-Type', 'text/plain'), @@ -18,6 +25,28 @@ class WSGIAppTests(unittest.TestCase): self.assertEqual(response.headerlist, headerlist) self.assertEqual(response.app_iter, [body]) + def test_decorator_alternate_iresponsefactory(self): + body = 'Unauthorized' + headerlist = [ ('Content-Type', 'text/plain'), + ('Content-Length', len(body)) ] + status = '401 Unauthorized' + def real_wsgiapp(environ, start_response): + start_response(status, headerlist) + return [body] + from repoze.bfg.wsgi import wsgiapp + wrapped = wsgiapp(real_wsgiapp) + context = DummyContext() + request = DummyRequest({}) + from repoze.bfg.interfaces import IResponseFactory + from zope.component import getGlobalSiteManager + from webob import Response + class Response2(Response): + pass + gsm = getGlobalSiteManager() + gsm.registerUtility(Response2, IResponseFactory) + response = wrapped(context, request) + self.failUnless(isinstance(response, Response2)) + def test_decorator_startresponse_uncalled(self): body = 'Unauthorized' headerlist = [ ('Content-Type', 'text/plain'), |
