示例#1
0
def test_sinatra_path():
    s = '/something'
    r = Router.sinatra_path_to_regex(s)
    assert r.match("/else") is None

    m = r.match(s)
    assert m is not None
    assert m.groupdict() == {}
示例#2
0
def test_sinatra_key():
    s = '/name/:name'
    r = Router.sinatra_path_to_regex(s)
    assert r.match("/not/right") is None

    matches = r.match("/name/growler")
    assert matches.group('name') == 'growler'

    gd = matches.groupdict()
    assert gd['name'] == 'growler'
示例#3
0
def test_sinatra_passes_regex():
    import re
    s = re.compile('/name/:name')
    r = Router.sinatra_path_to_regex(s)
    assert r.match("/not/right") is None
示例#4
0
def test_sinatra_path_groupdict(path, req_path, match_dict):
    r = Router.sinatra_path_to_regex(path)
    m = r.match(req_path)
    assert m.groupdict() == match_dict
示例#5
0
def test_sinatra_path_matches(path, req_path, matches):
    r = Router.sinatra_path_to_regex(path)
    assert (r.fullmatch(req_path) is not None) == matches
示例#6
0
def test_sinatra_passes_regex():
    import re
    s = re.compile('/name/:name')
    r = Router.sinatra_path_to_regex(s)
    assert r.match("/not/right") is None
示例#7
0
def test_sinatra_path_groupdict(path, req_path, match_dict):
    r = Router.sinatra_path_to_regex(path)
    m = r.match(req_path)
    assert m.groupdict() == match_dict
示例#8
0
def test_sinatra_path_matches(path, req_path, matches):
    r = Router.sinatra_path_to_regex(path)
    assert (r.fullmatch(req_path) is not None) == matches