From 44494c2d9d7266aede41c2ce72cb11b62c809b0a Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Thu, 21 Apr 2011 22:13:32 -0400 Subject: add an integration test for wsgiapp2 --- pyramid/tests/test_integration.py | 16 ++++++++++++++++ pyramid/tests/wsgiapp2app/__init__.py | 17 +++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 pyramid/tests/wsgiapp2app/__init__.py diff --git a/pyramid/tests/test_integration.py b/pyramid/tests/test_integration.py index e3a1a8003..dd77d3aec 100644 --- a/pyramid/tests/test_integration.py +++ b/pyramid/tests/test_integration.py @@ -390,6 +390,22 @@ class SelfScanAppTest(unittest.TestCase): res = self.testapp.get('/two', status=200) self.assertTrue('two' in res.body) +class WSGIApp2AppTest(unittest.TestCase): + def setUp(self): + from pyramid.tests.wsgiapp2app import main + config = main() + app = config.make_wsgi_app() + from webtest import TestApp + self.testapp = TestApp(app) + self.config = config + + def tearDown(self): + self.config.end() + + def test_hello(self): + res = self.testapp.get('/hello', status=200) + self.assertTrue('Hello' in res.body) + class DummyContext(object): pass diff --git a/pyramid/tests/wsgiapp2app/__init__.py b/pyramid/tests/wsgiapp2app/__init__.py new file mode 100644 index 000000000..0880556ef --- /dev/null +++ b/pyramid/tests/wsgiapp2app/__init__.py @@ -0,0 +1,17 @@ +from pyramid.view import view_config +from pyramid.wsgi import wsgiapp2 + +@view_config(name='hello', renderer='string') +@wsgiapp2 +def hello(environ, start_response): + assert environ['PATH_INFO'] == '/' + assert environ['SCRIPT_NAME'] == '/hello' + response_headers = [('Content-Type', 'text/plain')] + start_response('200 OK', response_headers) + return ['Hello!'] + +def main(): + from pyramid.config import Configurator + c = Configurator() + c.scan() + return c -- cgit v1.2.3