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__()
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' )
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
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_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")
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]
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
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
def test_lowerapproots(): create_request("/subthing/subsubthing/", {"SCRIPT_NAME": "/subthing/subsubthing"}) eq_("/subthing/subsubthing/foo", url("/foo"))
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)
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
def test_url_qualified(): """url() can handle list parameters, with unicode too""" create_request("/") value = url('/', qualified=True) assert value.startswith('http')
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
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
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
def test_lowerapproots(): create_request( '/subthing/subsubthing/', { 'SCRIPT_NAME' : '/subthing/subsubthing' } ) eq_("/subthing/subsubthing/foo", url("/foo"))
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)
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