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
+23 -13
View File
@@ -1,22 +1,12 @@
"""Suite-wide isolation of `Settings` from developer environment files.
`Settings.model_config` declares `env_file=".env.production"`, resolved relative to the
current working directory. Running pytest from the repository root therefore loads a real
developer env file into tests that construct `Settings(...)` directly, and the declared
field defaults stop being what the suite actually exercises.
That breaks verification in both directions: tests asserting default behavior fail locally
for environmental reasons, and tests asserting configured behavior can pass locally against
values that do not exist in CI. The autouse fixture in `conftest.py` neutralizes the class
level `env_file` so defaults are authoritative; tests that need file loading still pass
`_env_file=` explicitly, which takes precedence over the class config.
"""
"""Suite-wide isolation of `Settings` from developer environment files."""
from __future__ import annotations
from pathlib import Path
import transcription.config as config_module
from transcription.config import Settings
from transcription.config import resolve_settings_env_file_path
def test_settings_defaults_are_not_overridden_by_a_local_env_file():
@@ -37,3 +27,23 @@ def test_explicit_env_file_still_loads(tmp_path):
settings = Settings(openrouter_api_key="test-key", _env_file=env_path, _cli_parse_args=False)
assert settings.port == 9123
def test_settings_env_file_resolves_from_override_environment_variable(tmp_path, monkeypatch):
env_path = tmp_path / "custom.env"
env_path.write_text("PORT=9123\n", encoding="utf-8")
monkeypatch.setenv("ENV_FILE", str(env_path))
settings = Settings(openrouter_api_key="test-key", _cli_parse_args=False)
assert settings.port == 9123
def test_settings_default_env_path_is_anchored_to_project_root(tmp_path, monkeypatch):
monkeypatch.delenv("ENV_FILE", raising=False)
monkeypatch.chdir(tmp_path)
monkeypatch.setattr(config_module, "PROJECT_ROOT", tmp_path / "project-root")
resolved = resolve_settings_env_file_path()
assert resolved == tmp_path / "project-root" / ".env.production"