summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMike Burrows <mjb@asplake.co.uk>2010-01-09 21:18:20 +0000
committerMike Burrows <mjb@asplake.co.uk>2010-01-09 21:18:20 +0000
commiteddda4ddde63a90332c09ff89743cc29c605da29 (patch)
tree8e9f5202f76459ebc1b39978a9d46c058ac5f3e1 /tests
parentc7b94f4b1b146c9cb518a5ef45cf4948bbf03254 (diff)
downloadroutes-eddda4ddde63a90332c09ff89743cc29c605da29.tar.gz
Mapper.minimization now defaults to False
--HG-- branch : trunk
Diffstat (limited to 'tests')
-rw-r--r--tests/test_functional/test_generation.py37
-rw-r--r--tests/test_functional/test_middleware.py4
-rw-r--r--tests/test_functional/test_recognition.py55
-rw-r--r--tests/test_functional/test_utils.py11
-rw-r--r--tests/test_units/test_environment.py1
-rw-r--r--tests/test_units/test_mapper_str.py6
6 files changed, 111 insertions, 3 deletions
diff --git a/tests/test_functional/test_generation.py b/tests/test_functional/test_generation.py
index aa3718a..aa8e159 100644
--- a/tests/test_functional/test_generation.py
+++ b/tests/test_functional/test_generation.py
@@ -26,6 +26,7 @@ class TestGeneration(unittest.TestCase):
def test_dynamic_with_default(self):
for path in ['hi/:action', 'hi/:(action)']:
m = Mapper()
+ m.minimization = True
m.connect(path)
eq_('/hi', m.generate(action='index'))
@@ -35,6 +36,7 @@ class TestGeneration(unittest.TestCase):
def test_dynamic_with_false_equivs(self):
m = Mapper()
+ m.minimization = True
m.connect('article/:page', page=False)
m.connect(':controller/:action/:id')
@@ -47,18 +49,21 @@ class TestGeneration(unittest.TestCase):
eq_('/article', m.generate(page=None))
m = Mapper()
+ m.minimization = True
m.connect('view/:home/:area', home="austere", area=None)
eq_('/view/sumatra', m.generate(home='sumatra'))
eq_('/view/austere/chicago', m.generate(area='chicago'))
m = Mapper()
+ m.minimization = True
m.connect('view/:home/:area', home=None, area=None)
eq_('/view/None/chicago', m.generate(home=None, area='chicago'))
def test_dynamic_with_underscore_parts(self):
m = Mapper()
+ m.minimization = True
m.connect('article/:small_page', small_page=False)
m.connect(':(controller)/:(action)/:(id)')
@@ -70,6 +75,7 @@ class TestGeneration(unittest.TestCase):
def test_dynamic_with_false_equivs_and_splits(self):
m = Mapper()
+ m.minimization = True
m.connect('article/:(page)', page=False)
m.connect(':(controller)/:(action)/:(id)')
@@ -82,12 +88,14 @@ class TestGeneration(unittest.TestCase):
eq_('/article', m.generate(page=None))
m = Mapper()
+ m.minimization = True
m.connect('view/:(home)/:(area)', home="austere", area=None)
eq_('/view/sumatra', m.generate(home='sumatra'))
eq_('/view/austere/chicago', m.generate(area='chicago'))
m = Mapper()
+ m.minimization = True
m.connect('view/:(home)/:(area)', home=None, area=None)
eq_('/view/None/chicago', m.generate(home=None, area='chicago'))
@@ -106,6 +114,7 @@ class TestGeneration(unittest.TestCase):
def test_dynamic_with_default_and_regexp_condition(self):
for path in ['hi/:action', 'hi/:(action)']:
m = Mapper()
+ m.minimization = True
m.connect(path, requirements = {'action':'[a-z]+'})
eq_('/hi', m.generate(action='index'))
@@ -118,6 +127,7 @@ class TestGeneration(unittest.TestCase):
def test_path(self):
for path in ['hi/*file', 'hi/*(file)']:
m = Mapper()
+ m.minimization = True
m.connect(path)
eq_('/hi', m.generate(file=None))
@@ -128,6 +138,7 @@ class TestGeneration(unittest.TestCase):
def test_path_backwards(self):
for path in ['*file/hi', '*(file)/hi']:
m = Mapper()
+ m.minimization = True
m.connect(path)
eq_('/hi', m.generate(file=None))
@@ -156,6 +167,7 @@ class TestGeneration(unittest.TestCase):
def test_standard_route(self):
for path in [':controller/:action/:id', ':(controller)/:(action)/:(id)']:
m = Mapper()
+ m.minimization = True
m.connect(path)
eq_('/content', m.generate(controller='content', action='index'))
@@ -168,6 +180,7 @@ class TestGeneration(unittest.TestCase):
def test_multiroute(self):
m = Mapper()
+ m.minimization = True
m.connect('archive/:year/:month/:day', controller='blog', action='view', month=None, day=None,
requirements={'month':'\d{1,2}','day':'\d{1,2}'})
m.connect('viewpost/:id', controller='post', action='view')
@@ -181,6 +194,7 @@ class TestGeneration(unittest.TestCase):
def test_multiroute_with_splits(self):
m = Mapper()
+ m.minimization = True
m.connect('archive/:(year)/:(month)/:(day)', controller='blog', action='view', month=None, day=None,
requirements={'month':'\d{1,2}','day':'\d{1,2}'})
m.connect('viewpost/:(id)', controller='post', action='view')
@@ -194,6 +208,7 @@ class TestGeneration(unittest.TestCase):
def test_big_multiroute(self):
m = Mapper()
+ m.minimization = True
m.connect('', controller='articles', action='index')
m.connect('admin', controller='admin/general', action='index')
@@ -236,6 +251,7 @@ class TestGeneration(unittest.TestCase):
def test_big_multiroute_with_splits(self):
m = Mapper()
+ m.minimization = True
m.connect('', controller='articles', action='index')
m.connect('admin', controller='admin/general', action='index')
@@ -319,6 +335,7 @@ class TestGeneration(unittest.TestCase):
def test_no_extras(self):
m = Mapper()
+ m.minimization = True
m.connect(':controller/:action/:id')
m.connect('archive/:year/:month/:day', controller='blog', action='view', month=None, day=None)
@@ -326,6 +343,7 @@ class TestGeneration(unittest.TestCase):
def test_no_extras_with_splits(self):
m = Mapper()
+ m.minimization = True
m.connect(':(controller)/:(action)/:(id)')
m.connect('archive/:(year)/:(month)/:(day)', controller='blog', action='view', month=None, day=None)
@@ -342,6 +360,7 @@ class TestGeneration(unittest.TestCase):
def test_extras(self):
m = Mapper()
+ m.minimization = True
m.connect('viewpost/:id', controller='post', action='view')
m.connect(':controller/:action/:id')
@@ -351,6 +370,7 @@ class TestGeneration(unittest.TestCase):
def test_extras_with_splits(self):
m = Mapper()
+ m.minimization = True
m.connect('viewpost/:(id)', controller='post', action='view')
m.connect(':(controller)/:(action)/:(id)')
@@ -387,6 +407,8 @@ class TestGeneration(unittest.TestCase):
def test_typical(self):
for path in [':controller/:action/:id', ':(controller)/:(action)/:(id)']:
m = Mapper()
+ m.minimization = True
+ m.minimization = True
m.connect(path, action = 'index', id = None)
eq_('/content', m.generate(controller='content', action='index'))
@@ -401,6 +423,7 @@ class TestGeneration(unittest.TestCase):
def test_route_with_fixnum_default(self):
m = Mapper()
+ m.minimization = True
m.connect('page/:id', controller='content', action='show_page', id=1)
m.connect(':controller/:action/:id')
@@ -416,6 +439,7 @@ class TestGeneration(unittest.TestCase):
def test_route_with_fixnum_default_with_splits(self):
m = Mapper()
+ m.minimization = True
m.connect('page/:(id)', controller='content', action='show_page', id =1)
m.connect(':(controller)/:(action)/:(id)')
@@ -432,6 +456,7 @@ class TestGeneration(unittest.TestCase):
def test_uppercase_recognition(self):
for path in [':controller/:action/:id', ':(controller)/:(action)/:(id)']:
m = Mapper()
+ m.minimization = True
m.connect(path)
eq_('/Content', m.generate(controller='Content', action='index'))
@@ -442,6 +467,7 @@ class TestGeneration(unittest.TestCase):
def test_backwards(self):
m = Mapper()
+ m.minimization = True
m.connect('page/:id/:action', controller='pages', action='show')
m.connect(':controller/:action/:id')
@@ -450,6 +476,7 @@ class TestGeneration(unittest.TestCase):
def test_backwards_with_splits(self):
m = Mapper()
+ m.minimization = True
m.connect('page/:(id)/:(action)', controller='pages', action='show')
m.connect(':(controller)/:(action)/:(id)')
@@ -458,6 +485,7 @@ class TestGeneration(unittest.TestCase):
def test_both_requirement_and_optional(self):
m = Mapper()
+ m.minimization = True
m.connect('test/:year', controller='post', action='show', year=None, requirements = {'year':'\d{4}'})
eq_('/test', m.generate(controller='post', action='show'))
@@ -465,6 +493,7 @@ class TestGeneration(unittest.TestCase):
def test_set_to_nil_forgets(self):
m = Mapper()
+ m.minimization = True
m.connect('pages/:year/:month/:day', controller='content', action='list_pages', month=None, day=None)
m.connect(':controller/:action/:id')
@@ -483,6 +512,7 @@ class TestGeneration(unittest.TestCase):
def test_url_with_prefix(self):
m = Mapper()
+ m.minimization = True
m.prefix = '/blog'
m.connect(':controller/:action/:id')
m.create_regs(['content','blog','admin/comments'])
@@ -493,6 +523,7 @@ class TestGeneration(unittest.TestCase):
def test_url_with_prefix_deeper(self):
m = Mapper()
+ m.minimization = True
m.prefix = '/blog/phil'
m.connect(':controller/:action/:id')
m.create_regs(['content','blog','admin/comments'])
@@ -503,6 +534,7 @@ class TestGeneration(unittest.TestCase):
def test_url_with_environ_empty(self):
m = Mapper()
+ m.minimization = True
m.environ = dict(SCRIPT_NAME='')
m.connect(':controller/:action/:id')
m.create_regs(['content','blog','admin/comments'])
@@ -513,6 +545,7 @@ class TestGeneration(unittest.TestCase):
def test_url_with_environ(self):
m = Mapper()
+ m.minimization = True
m.environ = dict(SCRIPT_NAME='/blog')
m.connect(':controller/:action/:id')
m.create_regs(['content','blog','admin/comments'])
@@ -532,6 +565,7 @@ class TestGeneration(unittest.TestCase):
def test_url_with_environ_and_absolute(self):
m = Mapper()
+ m.minimization = True
m.environ = dict(SCRIPT_NAME='/blog')
m.connect('image', 'image/:name', _absolute=True)
m.connect(':controller/:action/:id')
@@ -545,6 +579,7 @@ class TestGeneration(unittest.TestCase):
def test_route_with_odd_leftovers(self):
m = Mapper()
+ m.minimization = True
m.connect(':controller/:(action)-:(id)')
m.create_regs(['content','blog','admin/comments'])
@@ -574,6 +609,7 @@ class TestGeneration(unittest.TestCase):
hoge = u'\u30c6\u30b9\u30c8' # the word test in Japanese
hoge_enc = urllib.quote(hoge.encode('utf-8'))
m = Mapper()
+ m.minimization = True
m.connect('google-jp', 'http://www.google.co.jp/search', _static=True)
m.create_regs(['messages'])
eq_("http://www.google.co.jp/search?q=" + hoge_enc, url_for('google-jp', q=hoge))
@@ -581,6 +617,7 @@ class TestGeneration(unittest.TestCase):
def test_other_special_chars(self):
m = Mapper()
+ m.minimization = True
m.connect('/:year/:(slug).:(format),:(locale)', locale='en', format='html')
m.create_regs(['content'])
diff --git a/tests/test_functional/test_middleware.py b/tests/test_functional/test_middleware.py
index ce5c3dc..de5b552 100644
--- a/tests/test_functional/test_middleware.py
+++ b/tests/test_functional/test_middleware.py
@@ -12,6 +12,7 @@ def simple_app(environ, start_response):
def test_basic():
map = Mapper()
+ map.minimization = True
map.connect(':controller/:action/:id')
map.create_regs(['content'])
app = TestApp(RoutesMiddleware(simple_app, map))
@@ -23,6 +24,7 @@ def test_basic():
def test_path_info():
map = Mapper()
+ map.minimization = True
map.connect('myapp/*path_info', controller='myapp')
map.connect('project/*path_info', controller='myapp')
map.create_regs(['content', 'myapp'])
@@ -44,6 +46,7 @@ def test_path_info():
def test_redirect_middleware():
map = Mapper()
+ map.minimization = True
map.connect('myapp/*path_info', controller='myapp')
map.redirect("faq/{section}", "/static/faq/{section}.html")
map.redirect("home/index", "/", _redirect_code='301 Moved Permanently')
@@ -69,6 +72,7 @@ def test_redirect_middleware():
def test_method_conversion():
map = Mapper()
+ map.minimization = True
map.connect('content/:type', conditions=dict(method='DELETE'))
map.connect(':controller/:action/:id')
map.create_regs(['content'])
diff --git a/tests/test_functional/test_recognition.py b/tests/test_functional/test_recognition.py
index a92cc11..6f79b12 100644
--- a/tests/test_functional/test_recognition.py
+++ b/tests/test_functional/test_recognition.py
@@ -12,6 +12,7 @@ class TestRecognition(unittest.TestCase):
def test_regexp_char_escaping(self):
m = Mapper()
+ m.minimization = True
m.connect(':controller/:(action).:(id)')
m.create_regs(['content'])
@@ -24,6 +25,7 @@ class TestRecognition(unittest.TestCase):
def test_all_static(self):
m = Mapper()
+ m.minimization = True
m.connect('hello/world/how/are/you', controller='content', action='index')
m.create_regs([])
@@ -37,6 +39,7 @@ class TestRecognition(unittest.TestCase):
hoge = u'\u30c6\u30b9\u30c8' # the word test in Japanese
hoge_enc = hoge.encode('utf-8')
m = Mapper()
+ m.minimization = True
m.connect(':hoge')
eq_({'controller': 'content', 'action': 'index', 'hoge': hoge},
m.match('/' + hoge_enc))
@@ -45,6 +48,7 @@ class TestRecognition(unittest.TestCase):
hoge = u'\u30c6\u30b9\u30c8' # the word test in Japanese
hoge_enc = urllib.quote(hoge.encode('utf-8'))
m = Mapper()
+ m.minimization = True
m.encoding = None
m.connect(':hoge')
eq_({'controller': 'content', 'action': 'index', 'hoge': hoge_enc},
@@ -53,6 +57,7 @@ class TestRecognition(unittest.TestCase):
def test_basic_dynamic(self):
for path in ['hi/:name', 'hi/:(name)']:
m = Mapper()
+ m.minimization = True
m.connect(path, controller='content')
m.create_regs([])
@@ -66,6 +71,7 @@ class TestRecognition(unittest.TestCase):
def test_basic_dynamic_backwards(self):
for path in [':name/hi', ':(name)/hi']:
m = Mapper()
+ m.minimization = True
m.connect(path)
m.create_regs([])
@@ -79,6 +85,7 @@ class TestRecognition(unittest.TestCase):
def test_dynamic_with_underscores(self):
m = Mapper()
+ m.minimization = True
m.connect('article/:small_page', small_page=False)
m.connect(':(controller)/:(action)/:(id)')
m.create_regs(['article', 'blog'])
@@ -89,6 +96,7 @@ class TestRecognition(unittest.TestCase):
def test_dynamic_with_default(self):
for path in ['hi/:action', 'hi/:(action)']:
m = Mapper()
+ m.minimization = True
m.connect(path, controller='content')
m.create_regs([])
@@ -102,6 +110,7 @@ class TestRecognition(unittest.TestCase):
def test_dynamic_with_default_backwards(self):
for path in [':action/hi', ':(action)/hi']:
m = Mapper()
+ m.minimization = True
m.connect(path, controller='content')
m.create_regs([])
@@ -116,6 +125,7 @@ class TestRecognition(unittest.TestCase):
def test_dynamic_with_string_condition(self):
for path in [':name/hi', ':(name)/hi']:
m = Mapper()
+ m.minimization = True
m.connect(path, controller='content', requirements={'name':'index'})
m.create_regs([])
@@ -129,6 +139,7 @@ class TestRecognition(unittest.TestCase):
def test_dynamic_with_string_condition_backwards(self):
for path in ['hi/:name', 'hi/:(name)']:
m = Mapper()
+ m.minimization = True
m.connect(path, controller='content', requirements={'name':'index'})
m.create_regs([])
@@ -142,6 +153,7 @@ class TestRecognition(unittest.TestCase):
def test_dynamic_with_regexp_condition(self):
for path in ['hi/:name', 'hi/:(name)']:
m = Mapper()
+ m.minimization = True
m.connect(path, controller='content', requirements={'name':'[a-z]+'})
m.create_regs([])
@@ -159,6 +171,7 @@ class TestRecognition(unittest.TestCase):
def test_dynamic_with_regexp_and_default(self):
for path in ['hi/:action', 'hi/:(action)']:
m = Mapper()
+ m.minimization = True
m.connect(path, controller='content', requirements={'action':'[a-z]+'})
m.create_regs([])
@@ -175,6 +188,7 @@ class TestRecognition(unittest.TestCase):
def test_dynamic_with_default_and_string_condition_backwards(self):
for path in [':action/hi', ':(action)/hi']:
m = Mapper()
+ m.minimization = True
m.connect(path)
m.create_regs([])
@@ -196,6 +210,7 @@ class TestRecognition(unittest.TestCase):
def test_multiroute(self):
m = Mapper()
+ m.minimization = True
m.connect('archive/:year/:month/:day', controller='blog', action='view', month=None, day=None,
requirements={'month':'\d{1,2}','day':'\d{1,2}'})
m.connect('viewpost/:id', controller='post', action='view')
@@ -231,6 +246,7 @@ class TestRecognition(unittest.TestCase):
def test_multiroute_with_splits(self):
m = Mapper()
+ m.minimization = True
m.connect('archive/:(year)/:(month)/:(day)', controller='blog', action='view', month=None, day=None,
requirements={'month':'\d{1,2}','day':'\d{1,2}'})
m.connect('viewpost/:(id)', controller='post', action='view')
@@ -248,6 +264,7 @@ class TestRecognition(unittest.TestCase):
def test_dynamic_with_regexp_defaults_and_gaps(self):
m = Mapper()
+ m.minimization = True
m.connect('archive/:year/:month/:day', controller='blog', action='view', month=None, day=None,
requirements={'month':'\d{1,2}'})
m.connect('view/:id/:controller', controller='blog', id=2, action='view', requirements={'id':'\d{1,2}'})
@@ -262,6 +279,7 @@ class TestRecognition(unittest.TestCase):
def test_dynamic_with_regexp_defaults_and_gaps_and_splits(self):
m = Mapper()
+ m.minimization = True
m.connect('archive/:(year)/:(month)/:(day)', controller='blog', action='view', month=None, day=None,
requirements={'month':'\d{1,2}'})
m.connect('view/:(id)/:(controller)', controller='blog', id=2, action='view', requirements={'id':'\d{1,2}'})
@@ -277,6 +295,7 @@ class TestRecognition(unittest.TestCase):
def test_dynamic_with_regexp_gaps_controllers(self):
for path in ['view/:id/:controller', 'view/:(id)/:(controller)']:
m = Mapper()
+ m.minimization = True
m.connect(path, id=2, action='view', requirements={'id':'\d{1,2}'})
m.create_regs(['post','blog','admin/user'])
@@ -290,6 +309,7 @@ class TestRecognition(unittest.TestCase):
def test_dynamic_with_trailing_strings(self):
for path in ['view/:id/:controller/super', 'view/:(id)/:(controller)/super']:
m = Mapper()
+ m.minimization = True
m.connect(path, controller='blog', id=2, action='view', requirements={'id':'\d{1,2}'})
m.create_regs(['post','blog','admin/user'])
@@ -304,6 +324,7 @@ class TestRecognition(unittest.TestCase):
def test_dynamic_with_trailing_non_keyword_strings(self):
m = Mapper()
+ m.minimization = True
m.connect('somewhere/:over/rainbow', controller='blog')
m.connect('somewhere/:over', controller='post')
m.create_regs(['post','blog','admin/user'])
@@ -316,6 +337,7 @@ class TestRecognition(unittest.TestCase):
def test_dynamic_with_trailing_dyanmic_defaults(self):
for path in ['archives/:action/:article', 'archives/:(action)/:(article)']:
m = Mapper()
+ m.minimization = True
m.connect(path, controller='blog')
m.create_regs(['blog'])
@@ -333,6 +355,7 @@ class TestRecognition(unittest.TestCase):
def test_path(self):
for path in ['hi/*file', 'hi/*(file)']:
m = Mapper()
+ m.minimization = True
m.connect(path, controller='content', action='download')
m.create_regs([])
@@ -346,6 +369,7 @@ class TestRecognition(unittest.TestCase):
def test_path_with_dynamic(self):
for path in [':controller/:action/*url', ':(controller)/:(action)/*(url)']:
m = Mapper()
+ m.minimization = True
m.connect(path)
m.create_regs(['content','admin/user'])
@@ -362,6 +386,7 @@ class TestRecognition(unittest.TestCase):
def test_path_with_dyanmic_and_default(self):
for path in [':controller/:action/*url', ':(controller)/:(action)/*(url)']:
m = Mapper()
+ m.minimization = True
m.connect(path, controller='content', action='view', url=None)
m.create_regs(['content','admin/user'])
@@ -377,6 +402,7 @@ class TestRecognition(unittest.TestCase):
def test_path_with_dynamic_and_default_backwards(self):
for path in ['*file/login', '*(file)/login']:
m = Mapper()
+ m.minimization = True
m.connect(path, controller='content', action='download', file=None)
m.create_regs([])
@@ -390,6 +416,7 @@ class TestRecognition(unittest.TestCase):
def test_path_backwards(self):
for path in ['*file/login', '*(file)/login']:
m = Mapper()
+ m.minimization = True
m.connect(path, controller='content', action='download')
m.create_regs([])
@@ -402,6 +429,7 @@ class TestRecognition(unittest.TestCase):
def test_path_backwards_with_controller(self):
m = Mapper()
+ m.minimization = True
m.connect('*url/login', controller='content', action='check_access')
m.connect('*url/:controller', action='view')
m.create_regs(['content', 'admin/user'])
@@ -420,6 +448,7 @@ class TestRecognition(unittest.TestCase):
def test_path_backwards_with_controller_and_splits(self):
m = Mapper()
+ m.minimization = True
m.connect('*(url)/login', controller='content', action='check_access')
m.connect('*(url)/:(controller)', action='view')
m.create_regs(['content', 'admin/user'])
@@ -438,6 +467,7 @@ class TestRecognition(unittest.TestCase):
def test_controller(self):
m = Mapper()
+ m.minimization = True
m.connect('hi/:controller', action='hi')
m.create_regs(['content','admin/user'])
@@ -452,6 +482,7 @@ class TestRecognition(unittest.TestCase):
def test_standard_route(self):
m = Mapper()
+ m.minimization = True
m.connect(':controller/:action/:id')
m.create_regs(['content','admin/user'])
@@ -468,6 +499,7 @@ class TestRecognition(unittest.TestCase):
def test_standard_route_with_gaps(self):
m = Mapper()
+ m.minimization = True
m.connect(':controller/:action/:(id).py')
m.create_regs(['content','admin/user'])
@@ -477,6 +509,7 @@ class TestRecognition(unittest.TestCase):
def test_standard_route_with_gaps_and_domains(self):
m = Mapper()
+ m.minimization = True
m.connect('manage/:domain.:ext', controller='admin/user', action='view', ext='html')
m.connect(':controller/:action/:id')
m.create_regs(['content','admin/user'])
@@ -492,6 +525,7 @@ class TestRecognition(unittest.TestCase):
def test_standard_with_domains(self):
m = Mapper()
+ m.minimization = True
m.connect('manage/:domain', controller='domains', action='view')
m.create_regs(['domains'])
@@ -499,6 +533,7 @@ class TestRecognition(unittest.TestCase):
def test_default_route(self):
m = Mapper()
+ m.minimization = True
m.connect('',controller='content',action='index')
m.create_regs(['content'])
@@ -511,6 +546,7 @@ class TestRecognition(unittest.TestCase):
def test_dynamic_with_prefix(self):
m = Mapper()
+ m.minimization = True
m.prefix = '/blog'
m.connect(':controller/:action/:id')
m.connect('', controller='content', action='index')
@@ -529,6 +565,7 @@ class TestRecognition(unittest.TestCase):
def test_dynamic_with_multiple_and_prefix(self):
m = Mapper()
+ m.minimization = True
m.prefix = '/blog'
m.connect(':controller/:action/:id')
m.connect('home/:action', controller='archive')
@@ -550,6 +587,7 @@ class TestRecognition(unittest.TestCase):
def test_splits_with_extension(self):
m = Mapper()
+ m.minimization = True
m.connect('hi/:(action).html', controller='content')
m.create_regs([])
@@ -562,6 +600,7 @@ class TestRecognition(unittest.TestCase):
def test_splits_with_dashes(self):
m = Mapper()
+ m.minimization = True
m.connect('archives/:(year)-:(month)-:(day).html', controller='archives', action='view')
m.create_regs([])
@@ -577,6 +616,7 @@ class TestRecognition(unittest.TestCase):
def test_splits_packed_with_regexps(self):
m = Mapper()
+ m.minimization = True
m.connect('archives/:(year):(month):(day).html', controller='archives', action='view',
requirements=dict(year=r'\d{4}',month=r'\d{2}',day=r'\d{2}'))
m.create_regs([])
@@ -595,6 +635,7 @@ class TestRecognition(unittest.TestCase):
def test_splits_with_slashes(self):
m = Mapper()
+ m.minimization = True
m.connect(':name/:(action)-:(day)', controller='content')
m.create_regs([])
@@ -608,6 +649,7 @@ class TestRecognition(unittest.TestCase):
def test_splits_with_slashes_and_default(self):
m = Mapper()
+ m.minimization = True
m.connect(':name/:(action)-:(id)', controller='content')
m.create_regs([])
@@ -629,6 +671,7 @@ class TestRecognition(unittest.TestCase):
def test_routematch(self):
m = Mapper()
+ m.minimization = True
m.connect(':controller/:action/:id')
m.create_regs(['content'])
route = m.matchlist[0]
@@ -640,6 +683,7 @@ class TestRecognition(unittest.TestCase):
def test_routematch_debug(self):
m = Mapper()
+ m.minimization = True
m.connect(':controller/:action/:id')
m.debug = True
m.create_regs(['content'])
@@ -655,6 +699,7 @@ class TestRecognition(unittest.TestCase):
def test_match_debug(self):
m = Mapper()
+ m.minimization = True
m.connect('nowhere', 'http://nowhere.com/', _static=True)
m.connect(':controller/:action/:id')
m.debug = True
@@ -671,6 +716,7 @@ class TestRecognition(unittest.TestCase):
def test_conditions(self):
m = Mapper()
+ m.minimization = True
m.connect('home/upload', controller='content', action='upload', conditions=dict(method=['POST']))
m.connect(':controller/:action/:id')
m.create_regs(['content', 'blog'])
@@ -696,6 +742,7 @@ class TestRecognition(unittest.TestCase):
def test_subdomains(self):
m = Mapper()
+ m.minimization = True
m.sub_domains = True
m.connect(':controller/:action/:id')
m.create_regs(['content', 'blog'])
@@ -725,6 +772,7 @@ class TestRecognition(unittest.TestCase):
def test_subdomains_with_conditions(self):
m = Mapper()
+ m.minimization = True
m.sub_domains = True
m.connect(':controller/:action/:id')
m.create_regs(['content', 'blog'])
@@ -759,6 +807,7 @@ class TestRecognition(unittest.TestCase):
def test_subdomain_with_conditions2(self):
m = Mapper()
+ m.minimization = True
m.sub_domains = True
m.connect('admin/comments', controller='admin', action='comments',
conditions={'sub_domain':True})
@@ -787,6 +836,7 @@ class TestRecognition(unittest.TestCase):
def test_subdomains_with_ignore(self):
m = Mapper()
+ m.minimization = True
m.sub_domains = True
m.sub_domains_ignore = ['www']
m.connect(':controller/:action/:id')
@@ -817,6 +867,7 @@ class TestRecognition(unittest.TestCase):
def test_other_special_chars(self):
m = Mapper()
+ m.minimization = True
m.connect('/:year/:(slug).:(format),:(locale)', format='html', locale='en')
m.connect('/error/:action/:id', controller='error')
m.create_regs(['content'])
@@ -837,6 +888,7 @@ class TestRecognition(unittest.TestCase):
def test_various_periods(self):
m = Mapper()
+ m.minimization = True
m.connect('sites/:site/pages/:page')
m.create_regs(['content'])
@@ -844,6 +896,7 @@ class TestRecognition(unittest.TestCase):
'site': u'python.com', 'page': u'index.html'},
m.match('/sites/python.com/pages/index.html'))
m = Mapper()
+ m.minimization = True
m.connect('sites/:site/pages/:page.:format', format='html')
m.create_regs(['content'])
@@ -853,6 +906,7 @@ class TestRecognition(unittest.TestCase):
def test_empty_fails(self):
m = Mapper()
+ m.minimization = True
m.connect(':controller/:action/:id')
m.connect('', controller='content', action='view', id=4)
m.create_regs(['content'])
@@ -865,6 +919,7 @@ class TestRecognition(unittest.TestCase):
def test_home_noargs(self):
m = Mapper(controller_scan=None, directory=None, explicit=True, always_scan=False)
+ m.minimization = True
m.connect('')
m.create_regs([])
diff --git a/tests/test_functional/test_utils.py b/tests/test_functional/test_utils.py
index 4a5a7b1..b5b8bcb 100644
--- a/tests/test_functional/test_utils.py
+++ b/tests/test_functional/test_utils.py
@@ -8,6 +8,7 @@ from routes import *
class TestUtils(unittest.TestCase):
def setUp(self):
m = Mapper()
+ m.minimization = True
m.connect('archive/:year/:month/:day', controller='blog', action='view', month=None, day=None,
requirements={'month':'\d{1,2}','day':'\d{1,2}'})
m.connect('viewpost/:id', controller='post', action='view')
@@ -444,6 +445,7 @@ class TestUtils(unittest.TestCase):
self.con.environ = dict(SCRIPT_NAME='', HTTP_HOST='example.com')
m = Mapper()
+ m.minimization = True
m.connect(':controller/:(action)-:(id).html')
m.connect('archives', 'archives/:year/:month/:day/:slug', controller='archives', action='view',
_filter=article_filter)
@@ -474,6 +476,7 @@ class TestUtils(unittest.TestCase):
self.con.environ = base_environ.copy()
m = Mapper()
+ m.minimization = True
m.connect(':controller/:action/:id')
m.create_regs(['content','archives','admin/comments'])
m.sub_domains = True
@@ -508,6 +511,7 @@ class TestUtils(unittest.TestCase):
self.con.mapper_dict = {}
m = Mapper()
+ m.minimization = True
m.connect(':controller/:action/:id')
m.create_regs(['content','archives','admin/comments'])
self.con.mapper = m
@@ -526,6 +530,7 @@ class TestUtils(unittest.TestCase):
self.con.environ = base_environ.copy()
m = Mapper()
+ m.minimization = True
m.sub_domains = True
m.connect(':controller/:action/:id')
m.create_regs(['content','archives','admin/comments'])
@@ -548,6 +553,7 @@ class TestUtils(unittest.TestCase):
self.con.environ = base_environ.copy()
m = Mapper()
+ m.minimization = True
m.sub_domains = True
m.sub_domains_ignore = ['www']
m.connect(':controller/:action/:id')
@@ -593,6 +599,7 @@ class TestUtils(unittest.TestCase):
self.con.environ = base_environ.copy()
m = Mapper()
+ m.minimization = True
m.sub_domains = True
m.connect(':controller/:action/:id')
m.connect('category_home', 'category/:section', controller='blog', action='view', section='home')
@@ -631,6 +638,7 @@ class TestUtils(unittest.TestCase):
self.con.environ = base_environ.copy()
m = Mapper()
+ m.minimization = True
m.sub_domains = True
m.connect(':controller/:action/:id')
m.connect('category_home', 'category/:section', controller='blog', action='view', section='home')
@@ -666,6 +674,7 @@ class TestUtils(unittest.TestCase):
controller_dir = os.path.join(os.path.dirname(here_dir),
os.path.join('test_files', 'controller_files'))
m = Mapper(directory=controller_dir)
+ m.minimization = True
m.always_scan = True
m.connect(':controller/:action/:id')
@@ -676,6 +685,7 @@ class TestUtils(unittest.TestCase):
class TestUtilsWithExplicit(unittest.TestCase):
def setUp(self):
m = Mapper(explicit=True)
+ m.minimization = True
m.connect('archive/:year/:month/:day', controller='blog', action='view', month=None, day=None,
requirements={'month':'\d{1,2}','day':'\d{1,2}'})
m.connect('viewpost/:id', controller='post', action='view', id=None)
@@ -750,6 +760,7 @@ class TestUtilsWithExplicit(unittest.TestCase):
def test_with_route_names(self):
m = self.con.mapper
+ m.minimization = True
self.con.mapper_dict = {}
m.connect('home', '', controller='blog', action='splash')
m.connect('category_home', 'category/:section', controller='blog', action='view', section='home')
diff --git a/tests/test_units/test_environment.py b/tests/test_units/test_environment.py
index e697d32..5385d96 100644
--- a/tests/test_units/test_environment.py
+++ b/tests/test_units/test_environment.py
@@ -4,6 +4,7 @@ import routes
class TestEnvironment(unittest.TestCase):
def setUp(self):
m = routes.Mapper()
+ m.minimization = True
m.connect('archive/:year/:month/:day', controller='blog', action='view', month=None, day=None,
requirements={'month':'\d{1,2}','day':'\d{1,2}'})
m.connect('viewpost/:id', controller='post', action='view')
diff --git a/tests/test_units/test_mapper_str.py b/tests/test_units/test_mapper_str.py
index f2a5b43..e6cea1b 100644
--- a/tests/test_units/test_mapper_str.py
+++ b/tests/test_units/test_mapper_str.py
@@ -10,9 +10,9 @@ class TestMapperStr(unittest.TestCase):
expected = """\
Route name Methods Path
- {controller}/{action}
-entries entries
-entry entries/{id}"""
+ /{controller}/{action}
+entries /entries
+entry /entries/{id}"""
for expected_line, actual_line in zip(expected.splitlines(), str(m).splitlines()):
assert expected_line == actual_line.rstrip()