예제 #1
0
def basic_check_uri(uri):
    nu = norm_u(uri)

    # idempotent 
    assert nu == norm_u(nu)

    # parsable 
    base_uri, qargs = parse_u(uri)

    # reconstructable
    assert nu == make_u(base_uri, qargs), '%s != %s' % (nu, make_u(base_uri, qargs))
예제 #2
0
def check_config(cfg):
    uri = make_u('http://www.exmaple.com/foo/bar', cfg)
    basic_check_uri(uri)

    b, qa = parse_u(uri)
    for k in cfg:
        assert k in qa
        assert qa[k] == cfg[k], '%s != %s' % (qa[k], cfg[k])
예제 #3
0
def test_nonascii():
    
    base = 'http://www.foo.bar.org/obs'
    args = {
        'abc' : u'\x94\x96\xc0',
        'def' : u'\x94\x96\xc0'.encode('utf-8'),
        u'\x96' : 'something else',
        u'\x96'.encode('utf-8') : 'foo'
    }

    uri = make_u(base, args)
    basic_check_uri(uri)
    basic_check_uri(unicode(uri))