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() == {}
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'
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
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
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