V6 Phase 1 complete
Quality Gate / gate (push) Failing after 49s

This commit is contained in:
Jim Lancaster
2026-08-25 10:38:45 -05:00
parent 0e43094b80
commit 867cc9eb78
14 changed files with 368 additions and 12 deletions
+49
View File
@@ -136,3 +136,52 @@ class TestAppLifespan:
pass
assert calls == ["logging", "schema", "recover", "worker_start", "worker_stop", "dispose_db"]
def test_startup_skips_embedded_worker_when_disabled(self, monkeypatch, tmp_path):
calls = []
monkeypatch.setattr("transcription.app.configure_logging", lambda _settings: calls.append("logging"))
monkeypatch.setattr("transcription.app.register_pages", lambda _app: None)
async def _create_all(**_kwargs):
calls.append("schema")
monkeypatch.setattr("transcription.app.create_all", _create_all)
monkeypatch.setattr(
"transcription.app.initialize_database_runtime",
lambda **_kwargs: type("_Runtime", (), {"engine": object(), "session_factory": object()})(),
)
async def _dispose_runtime():
calls.append("dispose_db")
monkeypatch.setattr("transcription.app.dispose_database_runtime", _dispose_runtime)
async def _recover_stale(_app):
calls.append("recover")
monkeypatch.setattr("transcription.app._recover_stale_processing_jobs", _recover_stale)
@asynccontextmanager
async def _worker_lifespan(**_kwargs):
calls.append("worker_start")
yield object(), object(), object()
calls.append("worker_stop")
monkeypatch.setattr("transcription.app.worker_consumer_lifespan", _worker_lifespan)
settings = Settings(
openrouter_api_key="test-key",
environment="test",
bootstrap_schema_on_startup=True,
run_embedded_worker=False,
upload_dir=tmp_path / "uploads",
prompt_dir=tmp_path / "prompts",
)
monkeypatch.setattr("transcription.app.get_settings", lambda: settings)
app = create_app()
with TestClient(app):
pass
assert calls == ["logging", "schema", "recover", "dispose_db"]
+1
View File
@@ -166,6 +166,7 @@ class TestWorkerReliabilitySettings:
def test_worker_retry_defaults(self):
"""worker retry settings default to no retries."""
settings = _make_settings()
assert settings.run_embedded_worker is True
assert settings.worker_max_retries == 0
assert settings.worker_stale_job_seconds == 30.0
assert settings.worker_retry_backoff_seconds == 1.0
+34
View File
@@ -0,0 +1,34 @@
"""Tests for the standalone worker service entrypoint."""
import pytest
from transcription import worker_service
@pytest.mark.unit
def test_main_runs_async_worker_once(monkeypatch):
calls: list[str] = []
async def _fake_run() -> None:
calls.append("run")
monkeypatch.setattr(worker_service, "_run", _fake_run)
worker_service.main()
assert calls == ["run"]
@pytest.mark.unit
def test_main_handles_keyboard_interrupt(monkeypatch):
calls: list[str] = []
def _raise_keyboard_interrupt(coro):
coro.close()
raise KeyboardInterrupt
monkeypatch.setattr(worker_service.asyncio, "run", _raise_keyboard_interrupt)
monkeypatch.setattr(worker_service.logger, "info", lambda _msg: calls.append("logged"))
worker_service.main()
assert calls == ["logged"]