"""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."""