Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_module_url(app):
with current_ctx(app, '/') as ctx:
ctx.request.language = 'it'
link = url('test_route')
assert link == '/it/test_route'
link = url('test_route2')
assert link == '/it/test2'
link = url('test_route2', [2])
assert link == '/it/test2/2'
link = url('test_route2', [2, 'foo'])
assert link == '/it/test2/2/foo'
link = url('test_route3')
assert link == '/it/test3'
link = url('test_route3', [2])
assert link == '/it/test3/2/foo'
link = url('test_route3', [2, 'bar'])
assert link == '/it/test3/2/foo/bar'
link = url('test_route3', [2, 'bar', 'json'])
assert link == '/it/test3/2/foo/bar.json'
link = url(
'test_route3', [2, 'bar', 'json'], {'foo': 'bar', 'bar': 'foo'})
lsplit = link.split('?')
assert lsplit[0] == '/it/test3/2/foo/bar.json'
assert lsplit[1] in ['foo=bar&bar=foo', 'bar=foo&foo=bar']
assert link == '/it/test_route'
link = url('test_route2')
assert link == '/it/test2'
link = url('test_route2', [2])
assert link == '/it/test2/2'
link = url('test_route2', [2, 'foo'])
assert link == '/it/test2/2/foo'
link = url('test_route3')
assert link == '/it/test3'
link = url('test_route3', [2])
assert link == '/it/test3/2/foo'
link = url('test_route3', [2, 'bar'])
assert link == '/it/test3/2/foo/bar'
link = url('test_route3', [2, 'bar', 'json'])
assert link == '/it/test3/2/foo/bar.json'
link = url(
'test_route3', [2, 'bar', 'json'], {'foo': 'bar', 'bar': 'foo'})
lsplit = link.split('?')
assert lsplit[0] == '/it/test3/2/foo/bar.json'
assert lsplit[1] in ['foo=bar&bar=foo', 'bar=foo&foo=bar']
def test_module_url(app):
with current_ctx(app, '/') as ctx:
ctx.request.language = 'it'
link = url('test_route')
assert link == '/it/test_route'
link = url('test_route2')
assert link == '/it/test2'
link = url('test_route2', [2])
assert link == '/it/test2/2'
link = url('test_route2', [2, 'foo'])
assert link == '/it/test2/2/foo'
link = url('test_route3')
assert link == '/it/test3'
link = url('test_route3', [2])
assert link == '/it/test3/2/foo'
link = url('test_route3', [2, 'bar'])
assert link == '/it/test3/2/foo/bar'
link = url('test_route3', [2, 'bar', 'json'])
assert link == '/it/test3/2/foo/bar.json'
link = url(
'test_route3', [2, 'bar', 'json'], {'foo': 'bar', 'bar': 'foo'})
lsplit = link.split('?')
assert lsplit[0] == '/it/test3/2/foo/bar.json'
assert lsplit[1] in ['foo=bar&bar=foo', 'bar=foo&foo=bar']
def test_module_url(app):
with current_ctx(app, '/') as ctx:
ctx.request.language = 'it'
link = url('test_route')
assert link == '/it/test_route'
link = url('test_route2')
assert link == '/it/test2'
link = url('test_route2', [2])
assert link == '/it/test2/2'
link = url('test_route2', [2, 'foo'])
assert link == '/it/test2/2/foo'
link = url('test_route3')
assert link == '/it/test3'
link = url('test_route3', [2])
assert link == '/it/test3/2/foo'
link = url('test_route3', [2, 'bar'])
assert link == '/it/test3/2/foo/bar'
link = url('test_route3', [2, 'bar', 'json'])
assert link == '/it/test3/2/foo/bar.json'
link = url(
link = url('test_route')
assert link == '/foo/test_route'
link = url('static', 'js/foo.js')
assert link == '/foo/static/js/foo.js'
app.config.static_version_urls = True
app.config.static_version = '1.0.0'
link = url('static', 'js/foo.js')
assert link == '/foo/static/_1.0.0/js/foo.js'
app.config.static_version_urls = False
ctx.request.language = 'it'
link = url('test_route')
assert link == '/foo/it/test_route'
link = url('static', 'js/foo.js')
assert link == '/foo/it/static/js/foo.js'
app.config.static_version_urls = True
app.config.static_version = '1.0.0'
link = url('static', 'js/foo.js')
assert link == '/foo/it/static/_1.0.0/js/foo.js'
link = url('static', 'js/foo.js')
assert link == '/foo/static/_1.0.0/js/foo.js'
app.config.static_version_urls = False
ctx.request.language = 'it'
link = url('test_route')
assert link == '/foo/it/test_route'
link = url('static', 'js/foo.js')
assert link == '/foo/it/static/js/foo.js'
app.config.static_version_urls = True
app.config.static_version = '1.0.0'
link = url('static', 'js/foo.js')
assert link == '/foo/it/static/_1.0.0/js/foo.js'
def test_static_url(app):
link = url('static', 'file')
assert link == '/static/file'
app.config.static_version_urls = True
app.config.static_version = '1.0.0'
link = url('static', 'js/foo.js', language='it')
assert link == '/it/static/_1.0.0/js/foo.js'
def test_static_url(app):
link = url('static', 'file')
assert link == '/static/file'
app.config.static_version_urls = True
app.config.static_version = '1.0.0'
link = url('static', 'js/foo.js', language='it')
assert link == '/it/static/_1.0.0/js/foo.js'