summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Bangert <ben@groovie.org>2010-02-20 18:27:20 -0500
committerBen Bangert <ben@groovie.org>2010-02-20 18:27:20 -0500
commitccc1c0e36dd312bdaa5f81e284ab6604a0932ba4 (patch)
tree493735750cb10045ab84fe08b6f8b2d200b7e15c
parente66d83c31582e3aa58e34eaa25e8d4cb5c7852d1 (diff)
downloadroutes-ccc1c0e36dd312bdaa5f81e284ab6604a0932ba4.tar.gz
Another module up to 100% test coverage
--HG-- branch : trunk
-rw-r--r--routes/middleware.py2
-rw-r--r--tests/test_functional/test_middleware.py28
2 files changed, 28 insertions, 2 deletions
diff --git a/routes/middleware.py b/routes/middleware.py
index 6c22ff6..0fa9a9e 100644
--- a/routes/middleware.py
+++ b/routes/middleware.py
@@ -119,8 +119,6 @@ class RoutesMiddleware(object):
environ['PATH_INFO'] = '/' + environ['PATH_INFO']
environ['SCRIPT_NAME'] += re.sub(r'^(.*?)/' + re.escape(newpath) + '$',
r'\1', oldpath)
- if environ['SCRIPT_NAME'].endswith('/'):
- environ['SCRIPT_NAME'] = environ['SCRIPT_NAME'][:-1]
response = self.app(environ, start_response)
diff --git a/tests/test_functional/test_middleware.py b/tests/test_functional/test_middleware.py
index 91434e3..cd87ebd 100644
--- a/tests/test_functional/test_middleware.py
+++ b/tests/test_functional/test_middleware.py
@@ -21,7 +21,35 @@ def test_basic():
res = app.get('/content')
assert "matchdict items are [('action', 'index'), ('controller', u'content'), ('id', None)]" in res
+
+def test_no_query():
+ 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)
+ env = {'PATH_INFO': '/', 'REQUEST_METHOD': 'GET'}
+ def start_response_wrapper(status, headers, exc=None):
+ pass
+ response = ''.join(app(env, start_response_wrapper))
+ assert 'matchdict items are []' in response
+
+def test_content_split():
+ 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)
+ 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
+
def test_path_info():
map = Mapper(explicit=False)
map.minimization = True