comparison tests/test_uriutil.py @ 329:422052d2e978

internal: Try handling URLs in a consistent way. * Now URLs passed to, and returned from, routes will always be absolute URLs, i.e. URLs including the site root. * Validate the site root at config loading time to make sure it starts and ends with a slash. * Get rid of unused stuff. * Add tests.
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 31 Mar 2015 23:03:28 -0700
parents eb958151c8dc
children d4321317beae
comparison
equal deleted inserted replaced
328:2a5996e0d3ec 329:422052d2e978
37 ('foo/bar/2.ext', ('foo/bar.ext', 2), False) 37 ('foo/bar/2.ext', ('foo/bar.ext', 2), False)
38 ]) 38 ])
39 def test_split_sub_uri(uri, expected, pretty_urls): 39 def test_split_sub_uri(uri, expected, pretty_urls):
40 app = mock.MagicMock() 40 app = mock.MagicMock()
41 app.config = { 41 app.config = {
42 'site/root': '/whatever/',
42 'site/pretty_urls': pretty_urls, 43 'site/pretty_urls': pretty_urls,
43 '__cache/pagination_suffix_re': '/(?P<num>\\d+)$'} 44 '__cache/pagination_suffix_re': '/(?P<num>\\d+)$'}
44 actual = split_sub_uri(app, uri) 45 actual = split_sub_uri(app, '/whatever/' + uri)
45 assert actual == expected 46 assert actual == ('/whatever/' + expected[0], expected[1])
46 47