mirror of
https://github.com/Donkie/Spoolman.git
synced 2026-10-19 00:29:46 -05:00
The unit tests are supposed to run with no database, no server and no built client, but tests/test_configjs.py imported spoolman.main, which builds the SPA handler at module level and so needs client_v2/build to exist. That passed locally, where the bundle is lying around, and failed CI's style job, which never builds the client. Moves the rendering into client.render_config_js, which the endpoint now calls, so the test exercises the real code path without the app.
19 lines
805 B
Python
19 lines
805 B
Python
"""Session-wide setup for the unit tests.
|
|
|
|
``env.get_data_dir()`` and its siblings create their directory as a side effect of being called,
|
|
so any test that reaches one -- directly, or by importing a module that does -- would otherwise
|
|
touch the same directory as the developer's live instance. Point them somewhere disposable
|
|
before any test module is imported. Nothing depends on this today; it is here so that the first
|
|
test that does cannot quietly reach into real data.
|
|
"""
|
|
|
|
import os
|
|
import tempfile
|
|
from pathlib import Path
|
|
|
|
_TMP_DIR = Path(tempfile.mkdtemp(prefix="spoolman-unit-tests-"))
|
|
|
|
os.environ.setdefault("SPOOLMAN_DIR_DATA", str(_TMP_DIR / "data"))
|
|
os.environ.setdefault("SPOOLMAN_DIR_LOGS", str(_TMP_DIR / "logs"))
|
|
os.environ.setdefault("SPOOLMAN_DIR_BACKUPS", str(_TMP_DIR / "backups"))
|