Files
bindery/tests/conftest.py
T
tim ca3d730129 Turn CWA off unless CWA_ENABLED is true
CWA_ENABLED now defaults to false. If a CWA variable is set while CWA is off, the start log has a warning that names it.

On the Settings page, the alert about INGEST_DIR moves to Book Downloads and shows with CWA on or off. The Uploads to CWA card moves below Book Downloads.
2026-10-06 16:59:15 +02:00

32 lines
893 B
Python

"""Point every directory at a temporary folder before the app modules load."""
import os
import tempfile
from pathlib import Path
_tmp = Path(tempfile.mkdtemp(prefix="bindery-tests-"))
for name, sub in [("CONFIG_DIR", "config"), ("INGEST_DIR", "ingest"), ("TMP_DIR", "tmp")]:
os.environ[name] = str(_tmp / sub)
(_tmp / "ingest").mkdir() # Bindery does not make the ingest folder
os.environ["BINDERY_START_THREADS"] = "false"
os.environ["UPDATE_INTERVAL_HOURS"] = "0"
os.environ["CWA_ENABLED"] = "true" # most tests are about a Bindery with CWA
for name in (
"CWA_URL",
"CWA_USERNAME",
"CWA_PASSWORD",
"CWA_DB_PATH",
"CALIBRE_DB_PATH",
"AUTH_METHOD",
"BINDERY_USERNAME",
"BINDERY_PASSWORD_HASH",
"BINDERY_API_KEY",
"URL_BASE",
"CWA_ALLOWED_USERS",
):
os.environ.pop(name, None)
from bindery import config # noqa: E402
config.prepare()