Add 4xx and 5xx http-code exception wrappers
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import pytest
|
||||
|
||||
from src.turbosloth.router import Router
|
||||
from src.turbosloth.exceptions import NotFoundException, MethodNotAllowedException
|
||||
|
||||
|
||||
def test_router_root_handler():
|
||||
@@ -46,7 +47,10 @@ def test_router_match():
|
||||
r = Router()
|
||||
r.add('GET', 'asdf', f)
|
||||
assert r.match('GET', '/asdf')
|
||||
with pytest.raises(ValueError, match='404'):
|
||||
with pytest.raises(NotFoundException, match='404\tNot Found: asd'):
|
||||
r.match('GET', 'asd')
|
||||
with pytest.raises(ValueError, match='405'):
|
||||
with pytest.raises(MethodNotAllowedException, match=f'405\tMethod Not Allowed: POST /asdf, allowed: GET'):
|
||||
r.match('POST', 'asdf')
|
||||
|
||||
with pytest.raises(MethodNotAllowedException, match=f'405\tMethod Not Allowed: POST /, allowed: none'):
|
||||
r.match('POST', '')
|
||||
|
||||
Reference in New Issue
Block a user