How to use the emmett.url function in emmett

To help you get started, we’ve selected a few emmett examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github emmett-framework / emmett / tests / test_routing.py View on Github external
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']
github emmett-framework / emmett / tests / test_routing.py View on Github external
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']
github emmett-framework / emmett / tests / test_routing.py View on Github external
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']
github emmett-framework / emmett / tests / test_routing.py View on Github external
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(
github emmett-framework / emmett / tests / test_routing.py View on Github external
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'
github emmett-framework / emmett / tests / test_routing.py View on Github external
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'
github emmett-framework / emmett / tests / test_routing.py View on Github external
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'
github emmett-framework / emmett / tests / test_routing.py View on Github external
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'