mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
change(fastapi): remove sqlite support
Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
0abdf8d468
commit
07aac768d6
2 changed files with 23 additions and 0 deletions
|
@ -48,6 +48,12 @@ async def app_startup():
|
|||
"TEST_RECURSION_LIMIT", sys.getrecursionlimit()))
|
||||
sys.setrecursionlimit(recursion_limit)
|
||||
|
||||
backend = aurweb.config.get("database", "backend")
|
||||
if backend not in aurweb.db.DRIVERS:
|
||||
raise ValueError(
|
||||
f"The configured database backend ({backend}) is unsupported. "
|
||||
f"Supported backends: {str(aurweb.db.DRIVERS.keys())}")
|
||||
|
||||
session_secret = aurweb.config.get("fastapi", "session_secret")
|
||||
if not session_secret:
|
||||
raise Exception("[fastapi] session_secret must not be empty")
|
||||
|
|
|
@ -45,3 +45,20 @@ async def test_asgi_http_exception_handler():
|
|||
response = await aurweb.asgi.http_exception_handler(None, exc)
|
||||
assert response.body.decode() == \
|
||||
f"<h1>{exc.status_code} {phrase}</h1><p>{exc.detail}</p>"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_asgi_app_unsupported_backends():
|
||||
config_get = aurweb.config.get
|
||||
|
||||
# Test that the previously supported "sqlite" backend is now
|
||||
# unsupported by FastAPI.
|
||||
def mock_sqlite_backend(section: str, key: str):
|
||||
if section == "database" and key == "backend":
|
||||
return "sqlite"
|
||||
return config_get(section, key)
|
||||
|
||||
with mock.patch("aurweb.config.get", side_effect=mock_sqlite_backend):
|
||||
expr = r"^.*\(sqlite\) is unsupported.*$"
|
||||
with pytest.raises(ValueError, match=expr):
|
||||
await aurweb.asgi.app_startup()
|
||||
|
|
Loading…
Add table
Reference in a new issue