fix: soft-deleted permission readd

This commit is contained in:
tao.chen
2026-09-02 10:10:41 +08:00
committed by tao.chen
parent 7c7e1a99a9
commit 36c402d407
5 changed files with 485 additions and 142 deletions
+32
View File
@@ -0,0 +1,32 @@
"""Shared test bootstrap.
Loads the repo-root ``.env`` so modules that import ``common.config``
(which is a process-wide singleton) can resolve ``APP_CONFIG_SECRET_KEY``
at collection time. Without it, any test importing ``backend.api.*`` fails
with a RuntimeError about ENC(...) ciphertext.
"""
from __future__ import annotations
import os
from pathlib import Path
_REPO_ROOT = Path(__file__).resolve().parent.parent.parent
def _bootstrap() -> None:
if os.environ.get("APP_CONFIG_SECRET_KEY"):
return
env_file = _REPO_ROOT / ".env"
if not env_file.is_file():
return
try:
from dotenv import dotenv_values
except ImportError:
return
value = dotenv_values(env_file).get("APP_CONFIG_SECRET_KEY")
if value:
os.environ["APP_CONFIG_SECRET_KEY"] = value
_bootstrap()