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