change(fastapi): remove sqlite support

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-11-17 00:27:44 -08:00
parent 0abdf8d468
commit 07aac768d6
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
2 changed files with 23 additions and 0 deletions

View file

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

View file

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