e49d12a72b
First automated coverage. 38 tests, run against the built image (which has the app deps); tests/ and requirements-dev.txt are not baked into the runtime image. - tests/test_dedup_gating.py: the safety-critical one. Drives dedup-library.sh's process_group with --apply + --only-paths and asserts ONLY the confirmed path is deleted and the higher-ranked FLAC is kept. - tests/test_pipeline_runner.py: lock skip, use_lock=False bypass, lock release, success/failure/timeout recording. - tests/test_db.py: schema version + idempotent migrations, FK-safe job-run pruning, stale-run reconciliation. - tests/test_credential_service.py: conf-field substitution incl. newline- injection safety, secret/non-secret classification, cookie-expiry parsing. - tests/test_playlist_service.py: cron round-trips, name validation, render. - tests/test_diagnostics.py: /health + /setup checks. - conftest.py points every path setting at throwaway temp dirs and a temp DB, so tests never touch a real library, /config, or the network. See tests/README.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
26 lines
817 B
Python
26 lines
817 B
Python
from app.services import diagnostics
|
|
|
|
|
|
def test_master_key_present():
|
|
# conftest wrote a real key at ENCRYPTION_KEY_FILE
|
|
assert diagnostics.master_key_present() is True
|
|
|
|
|
|
def test_oidc_not_configured_by_default():
|
|
assert diagnostics.oidc_configured() is False
|
|
|
|
|
|
def test_summary_degraded_without_oidc():
|
|
result = diagnostics.summary()
|
|
assert result["status"] == "degraded" # OIDC missing is critical
|
|
keys = {c["key"] for c in result["checks"]}
|
|
assert {"oidc", "master_key", "config_writable"} <= keys
|
|
|
|
|
|
def test_config_writable_true():
|
|
checks = {c["key"]: c for c in diagnostics.checks()}
|
|
assert checks["config_writable"]["ok"] is True
|
|
# critical checks are flagged as such
|
|
assert checks["oidc"]["critical"] is True
|
|
assert checks["beets_library"]["critical"] is False
|