Add key-value path subst matching

This commit is contained in:
2025-07-19 03:45:11 +03:00
parent 2943351442
commit 75824d1893
4 changed files with 47 additions and 25 deletions

View File

@@ -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')