Example #1
0
def test_lurl():
    """url() can handle list parameters, with unicode too"""
    create_request("/")
    value = lurl('/lurl')
    assert not isinstance(value, string_type)
    assert value.startswith('/lurl')
    assert str(value) == repr(value) == value.id == value.encode('utf-8').decode('utf-8') == value.__html__()
Example #2
0
def test_unicode():
    """url() can handle unicode parameters"""
    create_request("/")
    unicodestring =  u_('àèìòù')
    eq_(url('/', params=dict(x=unicodestring)),
        '/?x=%C3%A0%C3%A8%C3%AC%C3%B2%C3%B9'
        )
Example #3
0
def test_multi_values():
    create_request('/')
    r = url("/foo", params=dict(bar=("asdf", "qwer")))
    assert r in \
            ["/foo?bar=qwer&bar=asdf", "/foo?bar=asdf&bar=qwer"], r
    r = url("/foo", params=dict(bar=[1,2]))
    assert  r in \
            ["/foo?bar=1&bar=2", "/foo?bar=2&bar=1"], r
Example #4
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}')
    eq_(url('/', params=dict(x=unicodestring)),
        '/?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}"
    )
    eq_(url("/", x=unicodestring), "/?x=%C3%A0%C3%A8%C3%AC%C3%B2%C3%B9")
Example #6
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}')
    eq_(url('/', params=dict(x=unicodestring)),
        '/?x=%C3%A0%C3%A8%C3%AC%C3%B2%C3%B9'
        )
def test_lurl_as_HTTPFound_location():
    create_request('/')
    exc = HTTPFound(location=lurl('/lurl'))

    def _fake_start_response(*args, **kw):
        pass

    resp = exc({'PATH_INFO':'/',
                'wsgi.url_scheme': 'HTTP',
                'REQUEST_METHOD': 'GET',
                'SERVER_NAME': 'localhost',
                'SERVER_PORT': '80'}, _fake_start_response)
    assert b'resource was found at http://localhost:80/lurl' in resp[0]
Example #8
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, value
Example #9
0
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 #10
0
def test_lowerapproots():
    create_request("/subthing/subsubthing/", {"SCRIPT_NAME": "/subthing/subsubthing"})
    eq_("/subthing/subsubthing/foo", url("/foo"))
Example #11
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 #12
0
def test_lurl_format():
    """url() can handle list parameters, with unicode too"""
    create_request("/")
    value = lurl('/lurl/{0}')
    value = value.format('suburl')
    assert value == '/lurl/suburl', value
Example #13
0
def test_url_qualified():
    """url() can handle list parameters, with unicode too"""
    create_request("/")
    value = url('/', qualified=True)
    assert value.startswith('http')
Example #14
0
def test_list():
    """url() can handle list parameters, with unicode too"""
    create_request("/")
    value = url('/', params=dict(foo=['bar', u_('à')])),
    assert '/?foo=bar&foo=%C3%A0' in value, value
Example #15
0
def test_list():
    """url() can handle list parameters, with unicode too"""
    create_request("/")
    value = url(
        '/', params=dict(foo=['bar', u'\N{LATIN SMALL LETTER A WITH GRAVE}'])),
    assert '/?foo=bar&foo=%C3%A0' in value, value
Example #16
0
def test_list():
    """url() can handle list parameters, with unicode too"""
    create_request("/")
    value = url('/', params=dict(foo=['bar', u'\N{LATIN SMALL LETTER A WITH GRAVE}'])),
    assert '/?foo=bar&foo=%C3%A0' in value, value
Example #17
0
def test_lowerapproots():
    create_request(
                '/subthing/subsubthing/',
                { 'SCRIPT_NAME' : '/subthing/subsubthing' }
                )
    eq_("/subthing/subsubthing/foo", url("/foo"))
Example #18
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 #19
0
def test_lurl_radd():
    """url() can handle list parameters, with unicode too"""
    create_request("/")
    value = lurl('/lurl')
    value = '/suburl' + value
    assert value == '/suburl/lurl', value