Add key-value path subst matching
This commit is contained in:
@@ -46,7 +46,7 @@ def test_router_match():
|
||||
|
||||
r = Router()
|
||||
r.add('GET', 'asdf', f)
|
||||
assert r.match('GET', '/asdf')
|
||||
assert r.match('GET', '/asdf') == ({}, f)
|
||||
with pytest.raises(NotFoundException, match='404\tNot Found: asd'):
|
||||
r.match('GET', 'asd')
|
||||
with pytest.raises(MethodNotAllowedException, match=f'405\tMethod Not Allowed: POST /asdf, allowed: GET'):
|
||||
@@ -64,9 +64,9 @@ def test_router_pattern_match():
|
||||
r.add('GET', '/{some}/asdf', f)
|
||||
r.add('GET', '/{some}/b{some1}c', f)
|
||||
|
||||
assert r.match('GET', '/1234/asdf')
|
||||
assert r.match('GET', '/ /asdf')
|
||||
assert r.match('GET', '/ /basdfc')
|
||||
assert r.match('GET', '/1234/asdf') == ({'some': '1234'}, f)
|
||||
assert r.match('GET', '/ /asdf') == ({'some': ' '}, f)
|
||||
assert r.match('GET', '/ /basdfc') == ({'some': ' ', 'some1': 'asdf'}, f)
|
||||
|
||||
with pytest.raises(NotFoundException, match='404\tNot Found: asd'):
|
||||
r.match('GET', 'asd')
|
||||
|
||||
Reference in New Issue
Block a user