mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
change(fastapi): centralize HTTPException
Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
a747548254
commit
abfd41f31e
6 changed files with 28 additions and 51 deletions
|
@ -11,6 +11,8 @@ import aurweb.asgi
|
|||
import aurweb.config
|
||||
import aurweb.redis
|
||||
|
||||
from aurweb.testing.requests import Request
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_asgi_startup_session_secret_exception(monkeypatch):
|
||||
|
@ -42,9 +44,11 @@ async def test_asgi_startup_exception(monkeypatch):
|
|||
async def test_asgi_http_exception_handler():
|
||||
exc = HTTPException(status_code=422, detail="EXCEPTION!")
|
||||
phrase = http.HTTPStatus(exc.status_code).phrase
|
||||
response = await aurweb.asgi.http_exception_handler(None, exc)
|
||||
assert response.body.decode() == \
|
||||
f"<h1>{exc.status_code} {phrase}</h1><p>{exc.detail}</p>"
|
||||
response = await aurweb.asgi.http_exception_handler(Request(), exc)
|
||||
assert response.status_code == 422
|
||||
content = response.body.decode()
|
||||
assert f"{exc.status_code} - {phrase}" in content
|
||||
assert "EXCEPTION!" in content
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue