Begin implementation of Step 1. Implementation interrupted when I ran out of credits at openrouter. Credits added. Now trying to figure out how to restart the process...

This commit is contained in:
Jim Lancaster
2026-06-24 11:09:02 -05:00
parent bf23893477
commit 5165fa64bc
18 changed files with 592 additions and 108 deletions
View File
+22
View File
@@ -0,0 +1,22 @@
"""Shared test fixtures.
Every test gets a fresh in-memory SQLite database so tests are
isolated, fast, and leave no artifacts on disk.
"""
import pytest
from sqlmodel import Session, SQLModel, create_engine
from sqlmodel.pool import StaticPool
@pytest.fixture
def session():
"""Provide a clean database session for each test."""
engine = create_engine(
"sqlite://",
connect_args={"check_same_thread": False},
poolclass=StaticPool,
)
SQLModel.metadata.create_all(engine)
with Session(engine) as session:
yield session
+33
View File
@@ -0,0 +1,33 @@
"""Tests for transcription.config — settings loading, provider defaults, and paths."""
from transcription.config import Provider, Settings
class TestSettingsLoading:
"""Verify Settings construction and required-field validation."""
def test_loads_from_env(self):
"""Settings constructs when OPENROUTER_API_KEY is provided."""
def test_requires_api_key(self):
"""Settings raises ValidationError when OPENROUTER_API_KEY is missing."""
class TestProviderSettings:
"""Verify provider enum defaults and validation."""
def test_defaults_to_openrouter(self):
"""Default provider is openrouter when not explicitly set."""
def test_rejects_invalid_value(self):
"""Setting PROVIDER to an invalid value raises ValidationError."""
def test_optional_fields_default_to_none(self):
"""provider_model, openrouter_http_referer, and openrouter_app_title are None when unset."""
class TestPathSettings:
"""Verify filesystem path field types."""
def test_path_fields_are_path_objects(self):
"""upload_dir and prompt_dir are Path instances."""
+18
View File
@@ -0,0 +1,18 @@
"""Tests for transcription.db — schema bootstrap and session factory."""
class TestSchemaBootstrap:
"""Verify create_all produces the expected table set."""
def test_create_all_creates_expected_tables(self):
"""After create_all(), document, job, and transcript tables exist."""
class TestSessionFactory:
"""Verify get_session yields and cleans up sessions."""
def test_get_session_yields_session(self):
"""get_session() yields a usable Session object."""
def test_session_is_closed_after_generator_exit(self):
"""After the context manager exits, the session is closed."""
+52
View File
@@ -0,0 +1,52 @@
"""Tests for transcription.models — Document, Job, Transcript persistence and relationships."""
from transcription.models import Document, Job, JobStatus, Transcript
class TestDocumentModel:
"""Verify Document creation and default field population."""
def test_can_be_persisted(self, session):
"""A Document round-trips through the database with correct fields."""
def test_defaults_are_populated(self, session):
"""id is a UUID and uploaded_at is populated on creation."""
class TestJobModel:
"""Verify Job creation, defaults, and status transitions."""
def test_can_be_created_for_document(self, session):
"""A Job linked to a Document via FK persists correctly."""
def test_defaults_are_populated(self, session):
"""Default status is queued; created_at and updated_at are populated."""
def test_transitions_to_transcribed(self, session):
"""Status updates from queued to processing to transcribed."""
def test_transitions_to_failed(self, session):
"""Status updates from processing to failed."""
class TestTranscriptModel:
"""Verify Transcript persistence for success and failure cases."""
def test_success_record_persists(self, session):
"""A Transcript with text set and error_detail None persists correctly."""
def test_failure_record_persists(self, session):
"""A Transcript with text None and error_detail set persists correctly."""
def test_job_id_is_unique(self, session):
"""Inserting two transcripts with the same job_id raises an integrity error."""
class TestRelationships:
"""Verify SQLModel relationship navigation between models."""
def test_document_exposes_jobs(self, session):
"""document.jobs returns the linked Job list."""
def test_job_exposes_transcript(self, session):
"""job.transcript returns the linked Transcript."""