Example #1
0
def test_list():
    """url() can handle list parameters, with unicode too"""
    create_request("/")
    eq_(
        url('/', foo=['bar', u'\N{LATIN SMALL LETTER A WITH GRAVE}']),
        '/?foo=bar&foo=%C3%A0'
    )
def test_multi_values():
    create_request('/')
    r = url("/foo", bar=(u"asdf",u"qwer"))
    assert r in \
            ["/foo?bar=qwer&bar=asdf", "/foo?bar=asdf&bar=qwer"], r
    r = url("/foo", bar=[1,2])
    assert  r in \
            ["/foo?bar=1&bar=2", "/foo?bar=2&bar=1"], r
Example #3
0
def test_basicurls():
    create_request('/')
    eq_('/foo', url('/foo'))
    eq_('foo/bar', url(["foo", "bar"]))
    assert url("/foo", bar=1, baz=2) in \
            ["/foo?bar=1&baz=2", "/foo?baz=2&bar=1"]
    assert url("/foo", dict(bar=1, baz=2)) in \
            ["/foo?bar=1&baz=2", "/foot?baz=2&bar=1"]
    assert url("/foo", dict(bar=1, baz=None)) == "/foo?bar=1"
Example #4
0
def test_unicode():
    """url() can handle unicode parameters"""
    create_request("/")
    eq_(url('/', x=u'\N{LATIN SMALL LETTER A WITH GRAVE}'
        u'\N{LATIN SMALL LETTER E WITH GRAVE}'
        u'\N{LATIN SMALL LETTER I WITH GRAVE}'
        u'\N{LATIN SMALL LETTER O WITH GRAVE}'
        u'\N{LATIN SMALL LETTER U WITH GRAVE}'),
        '/?x=%C3%A0%C3%A8%C3%AC%C3%B2%C3%B9'
        )
Example #5
0
def test_unicode():
    """url() can handle unicode parameters"""
    create_request("/")
    unicodestring = (u'\N{LATIN SMALL LETTER A WITH GRAVE}'
        u'\N{LATIN SMALL LETTER E WITH GRAVE}'
        u'\N{LATIN SMALL LETTER I WITH GRAVE}'
        u'\N{LATIN SMALL LETTER O WITH GRAVE}'
        u'\N{LATIN SMALL LETTER U WITH GRAVE}')
    print url(unicodestring)
    eq_(url('/', x=unicodestring),
        '/?x=%C3%A0%C3%A8%C3%AC%C3%B2%C3%B9'
        )
Example #6
0
def test_approotsWithPath():
    create_request('/coolsite/root/subthing/', {'SCRIPT_NAME' : '/subthing'})
    pylons.config.update({"server.webpath":"/coolsite/root"})
    eq_("/coolsite/root/subthing/foo", url("/foo"))
Example #7
0
def test_multi_values():
    create_request('/')
    assert url("/foo", bar=[1,2]) in \
            ["/foo?bar=1&bar=2", "/foo?bar=2&bar=1"]
    assert url("/foo", bar=("asdf","qwer")) in \
            ["/foo?bar=qwer&bar=asdf", "/foo?bar=asdf&bar=qwer"]
Example #8
0
def test_lowerapproots():
    create_request(
                '/subthing/subsubthing/', 
                { 'SCRIPT_NAME' : '/subthing/subsubthing' }
                )
    eq_("/subthing/subsubthing/foo", url("/foo"))
Example #9
0
def test_create_request():
    environ = { 'SCRIPT_NAME' : '/xxx' }
    request = create_request('/', environ)
    eq_('http://localhost/xxx/hello', tg.request.relative_url('hello'))
    eq_('http://localhost/xxx', tg.request.application_url)
Example #10
0
def test_list():
    """url() can handle list parameters, with unicode too"""
    create_request("/")
    value = url('/', foo=['bar', u'\N{LATIN SMALL LETTER A WITH GRAVE}']),
    assert '/?foo=bar&foo=%C3%A0' in value
Example #11
0
def test_multi_values():
    create_request('/')
    assert url("/foo", bar=[1,2]) in \
            ["/foo?bar=1&bar=2", "/foo?bar=2&bar=1"]
    assert url("/foo", bar=("asdf","qwer")) in \
            ["/foo?bar=qwer&bar=asdf", "/foo?bar=asdf&bar=qwer"]
Example #12
0
def test_lowerapproots():
    create_request(
                '/subthing/subsubthing/',
                { 'SCRIPT_NAME' : '/subthing/subsubthing' }
                )
    eq_("/subthing/subsubthing/foo", url("/foo"))
Example #13
0
def test_create_request():
    environ = { 'SCRIPT_NAME' : '/xxx' }
    request = create_request('/', environ)
    eq_('http://localhost/xxx/hello', tg.request.relative_url('hello'))
    eq_('http://localhost/xxx', tg.request.application_url)