CI: Test core/views/generic.py enabling and disabling extensions (#774)

This commit is contained in:
calle
2022-07-23 11:58:29 +02:00
committed by GitHub
parent bf2a3e9df2
commit 32a8736f32
2 changed files with 71 additions and 1 deletions
+9
View File
@@ -23,6 +23,7 @@ from lnbits.settings import (
SERVICE_FEE,
)
from ...helpers import get_valid_extensions
from ..crud import (
create_account,
create_wallet,
@@ -66,6 +67,14 @@ async def extensions(
HTTPStatus.BAD_REQUEST, "You can either `enable` or `disable` an extension."
)
# check if extension exists
if extension_to_enable or extension_to_disable:
ext = extension_to_enable or extension_to_disable
if ext not in [e.code for e in get_valid_extensions()]:
raise HTTPException(
HTTPStatus.BAD_REQUEST, f"Extension '{ext}' doesn't exist."
)
if extension_to_enable:
logger.info(f"Enabling extension: {extension_to_enable} for user {user.id}")
await update_user_extension(