mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
add aurweb.db.session
+ Added Session class and global session object to aurweb.db, these are sessions created by sqlalchemy ORM's sessionmaker and will allow us to use declarative/imperative models. Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
7c65604dad
commit
4238a9fc68
6 changed files with 260 additions and 32 deletions
29
test/test_asgi.py
Normal file
29
test/test_asgi.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
import http
|
||||
import os
|
||||
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
from fastapi import HTTPException
|
||||
|
||||
import aurweb.asgi
|
||||
import aurweb.config
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_asgi_startup_exception(monkeypatch):
|
||||
with mock.patch.dict(os.environ, {"AUR_CONFIG": "conf/config.defaults"}):
|
||||
aurweb.config.rehash()
|
||||
with pytest.raises(Exception):
|
||||
await aurweb.asgi.app_startup()
|
||||
aurweb.config.rehash()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
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>"
|
Loading…
Add table
Add a link
Reference in a new issue