Implement rec - Phase 4 complete
Quality Gate / gate (push) Successful in 2m38s

This commit is contained in:
Jim Lancaster
2026-09-02 16:23:09 -05:00
parent 27ec81ca5b
commit 6f4accf275
13 changed files with 98 additions and 141 deletions
+10 -6
View File
@@ -4,6 +4,7 @@ Every test gets a fresh in-memory SQLite database so tests are
isolated, fast, and leave no artifacts on disk.
"""
import os
from pathlib import Path
import pytest
@@ -28,9 +29,9 @@ from transcription.services.jobs import JobService
def isolate_settings_from_local_env_files(tmp_path_factory):
"""Point `Settings` at a controlled stub env file instead of a developer one.
`Settings.model_config` declares `env_file=".env.production"`, resolved against the
current working directory, so a repository-root pytest run would otherwise read real
deployment values into tests that assert declared defaults.
`Settings()` resolves its env file through the shared config seam, so a repository-root
pytest run would otherwise read a developer's real `.env.production` into tests that
assert declared defaults.
The stub mirrors what `.github/workflows/quality-gate.yml` writes in CI: only
`OPENROUTER_API_KEY`, which is required and which many tests need `get_settings()` to
@@ -42,12 +43,15 @@ def isolate_settings_from_local_env_files(tmp_path_factory):
stub = tmp_path_factory.mktemp("settings-env") / ".env.test"
stub.write_text("OPENROUTER_API_KEY=test-placeholder-not-a-real-key\n", encoding="utf-8")
original = Settings.model_config.get("env_file")
Settings.model_config["env_file"] = str(stub)
original = os.environ.get("ENV_FILE")
os.environ["ENV_FILE"] = str(stub)
try:
yield
finally:
Settings.model_config["env_file"] = original
if original is None:
os.environ.pop("ENV_FILE", None)
else:
os.environ["ENV_FILE"] = original
@pytest.fixture