summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBen Bangert <ben@groovie.org>2010-02-28 10:56:46 -0800
committerBen Bangert <ben@groovie.org>2010-02-28 10:56:46 -0800
commit70248103ac63d6a763bf1d8f067d8f3751aa74d9 (patch)
tree7ab431f1842ec4f28b5e71c814a8fb97258d6a88 /tests
parent1c02dc6d28ad9eee37263a343f30d4a11ba0f685 (diff)
downloadroutes-70248103ac63d6a763bf1d8f067d8f3751aa74d9.tar.gz
Ensure singleton usage is still default in middleware so Routes upgrade doesn't break url_for users.
--HG-- branch : trunk
Diffstat (limited to 'tests')
-rw-r--r--tests/test_functional/test_middleware.py27
1 files changed, 25 insertions, 2 deletions
diff --git a/tests/test_functional/test_middleware.py b/tests/test_functional/test_middleware.py
index cd87ebd..6b51901 100644
--- a/tests/test_functional/test_middleware.py
+++ b/tests/test_functional/test_middleware.py
@@ -30,7 +30,7 @@ def test_no_query():
map.create_regs(['content', 'myapp'])
app = RoutesMiddleware(simple_app, map)
- env = {'PATH_INFO': '/', 'REQUEST_METHOD': 'GET'}
+ env = {'PATH_INFO': '/', 'REQUEST_METHOD': 'GET', 'HTTP_HOST': 'localhost'}
def start_response_wrapper(status, headers, exc=None):
pass
response = ''.join(app(env, start_response_wrapper))
@@ -44,11 +44,34 @@ def test_content_split():
map.create_regs(['content', 'myapp'])
app = RoutesMiddleware(simple_app, map)
+ env = {'PATH_INFO': '/', 'REQUEST_METHOD': 'POST', 'CONTENT_TYPE': 'text/plain;text/html',
+ 'HTTP_HOST': 'localhost'}
+ def start_response_wrapper(status, headers, exc=None):
+ pass
+ response = ''.join(app(env, start_response_wrapper))
+ assert 'matchdict items are []' in response
+
+def test_no_singleton():
+ map = Mapper(explicit=False)
+ map.minimization = True
+ map.connect('myapp/*path_info', controller='myapp')
+ map.connect('project/*path_info', controller='myapp')
+ map.create_regs(['content', 'myapp'])
+
+ app = RoutesMiddleware(simple_app, map, singleton=False)
env = {'PATH_INFO': '/', 'REQUEST_METHOD': 'POST', 'CONTENT_TYPE': 'text/plain;text/html'}
def start_response_wrapper(status, headers, exc=None):
pass
response = ''.join(app(env, start_response_wrapper))
- assert 'matchdict items are []' in response
+ assert 'matchdict items are []' in response
+
+ # Now a match
+ env = {'PATH_INFO': '/project/fred', 'REQUEST_METHOD': 'POST', 'CONTENT_TYPE': 'text/plain;text/html'}
+ def start_response_wrapper(status, headers, exc=None):
+ pass
+ response = ''.join(app(env, start_response_wrapper))
+ assert "matchdict items are [('action', u'index'), ('controller', u'myapp'), ('path_info', 'fred')]" in response
+
def test_path_info():
map = Mapper(explicit=False)