mirror of
https://github.com/Donkie/Spoolman.git
synced 2026-10-22 01:52:17 -05:00
Task 10: config.js JSON-encodes the base path, so a backslash cannot escape the string literal the way the old " check allowed; search.py escapes LIKE wildcards at both its call sites, using a helper moved into database/utils.py so it and extra_field_query share one implementation. Task 9 was a pair of decisions rather than fixes. /info keeps its paths: both clients render them and removing response fields breaks API v1, while the disclosure buys nothing against an API that is unauthenticated anyway. /metrics keeps its shape but now says what it publishes when switched on. Also pins the unit tests to a throwaway data directory -- importing spoolman.main creates one as a side effect, and it was the real one.
18 lines
730 B
Python
18 lines
730 B
Python
"""Session-wide setup for the unit tests.
|
|
|
|
Importing ``spoolman.main`` (or anything that reads ``env.get_data_dir()``) creates the data
|
|
directory as a side effect, which would otherwise be the *real* one -- a developer running
|
|
``poe test`` would find the suite reaching into the same directory as their live instance.
|
|
Point the directories at a throwaway location before any test module is imported.
|
|
"""
|
|
|
|
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"))
|