Pre-publication review draft
日常訳NICHIJOYAKU日本語 ↗

OPEN SOURCE

software/tests/test_orchestration_models.py

Read on this site and download the files you need.

Nichijoyaku was created using AI. A complete review by human biblical-language and biblical-studies specialists has not been established. Read alongside established translations and original-language resources.

← Back to the open-source guide

software/tests/test_orchestration_models.py279 linesDownload this file ↓

This is the same source included in the download. Each line number is a link you can save or share.

File verification detailsSHA-256 691af3389a1b7d729aa0b3af3cb11c7da88fbc0ab8ac5424f70af3822bdf09f8
1"""Tests for orchestration models."""23from __future__ import annotations45from datetime import datetime67import pytest89from src.orchestration.models import (10    ALL_BOOKS,11    NEW_TESTAMENT_BOOKS,12    OLD_TESTAMENT_BOOKS,13    BibleJob,14    BookJob,15    BookResult,16    JobResult,17    JobStatus,18    VerseJob,19)202122class TestJobStatus:23    """Tests for JobStatus enum."""2425    def test_status_values(self) -> None:26        """Test that all expected status values exist."""27        assert JobStatus.PENDING == "pending"28        assert JobStatus.IN_PROGRESS == "in_progress"29        assert JobStatus.COMPLETED == "completed"30        assert JobStatus.FAILED == "failed"31        assert JobStatus.CANCELLED == "cancelled"3233    def test_status_is_string_enum(self) -> None:34        """Test that status values can be used as strings."""35        assert str(JobStatus.PENDING) == "JobStatus.PENDING"36        assert JobStatus.PENDING.value == "pending"373839class TestVerseJob:40    """Tests for VerseJob dataclass."""4142    def test_default_values(self) -> None:43        """Test default values for VerseJob."""44        job = VerseJob(book="john", chapter=1, verse=1)45        assert job.book == "john"46        assert job.chapter == 147        assert job.verse == 148        assert job.status == JobStatus.PENDING49        assert job.attempts == 050        assert job.last_error is None51        assert job.worker_pid is None52        assert job.started_at is None53        assert job.completed_at is None5455    def test_reference_str(self) -> None:56        """Test reference_str property."""57        job = VerseJob(book="john", chapter=3, verse=16)58        assert job.reference_str == "john:3:16"5960    def test_with_values(self) -> None:61        """Test VerseJob with all values set."""62        now = datetime.utcnow()63        job = VerseJob(64            book="genesis",65            chapter=1,66            verse=1,67            status=JobStatus.IN_PROGRESS,68            attempts=2,69            last_error="Rate limit exceeded",70            worker_pid=12345,71            started_at=now,72        )73        assert job.status == JobStatus.IN_PROGRESS74        assert job.attempts == 275        assert job.last_error == "Rate limit exceeded"76        assert job.worker_pid == 1234577        assert job.started_at == now787980class TestBookJob:81    """Tests for BookJob dataclass."""8283    def test_default_values(self) -> None:84        """Test default values for BookJob."""85        job = BookJob(book="john")86        assert job.book == "john"87        assert job.status == JobStatus.PENDING88        assert job.total_verses == 089        assert job.completed_verses == 090        assert job.failed_verses == 091        assert job.worker_pid is None92        assert job.started_at is None93        assert job.completed_at is None94        assert job.error_message is None9596    def test_pending_verses(self) -> None:97        """Test pending_verses property."""98        job = BookJob(99            book="john",100            total_verses=100,101            completed_verses=50,102            failed_verses=10,103        )104        assert job.pending_verses == 40105106    def test_progress_percentage(self) -> None:107        """Test progress_percentage property."""108        job = BookJob(109            book="john",110            total_verses=100,111            completed_verses=75,112        )113        assert job.progress_percentage == 75.0114115    def test_progress_percentage_zero_total(self) -> None:116        """Test progress_percentage with zero total."""117        job = BookJob(book="john", total_verses=0)118        assert job.progress_percentage == 0.0119120121class TestBibleJob:122    """Tests for BibleJob dataclass."""123124    def test_default_values(self) -> None:125        """Test default values for BibleJob."""126        job = BibleJob()127        assert job.job_id is not None128        assert len(job.job_id) == 36  # UUID format129        assert job.books == []130        assert job.status == JobStatus.PENDING131        assert job.config_snapshot == {}132        assert job.created_at is not None133        assert job.started_at is None134        assert job.completed_at is None135        assert job.total_verses == 0136        assert job.completed_verses == 0137        assert job.failed_verses == 0138139    def test_pending_verses(self) -> None:140        """Test pending_verses property."""141        job = BibleJob(142            total_verses=1000,143            completed_verses=500,144            failed_verses=50,145        )146        assert job.pending_verses == 450147148    def test_progress_percentage(self) -> None:149        """Test progress_percentage property."""150        job = BibleJob(151            total_verses=1000,152            completed_verses=250,153        )154        assert job.progress_percentage == 25.0155156    def test_progress_percentage_zero_total(self) -> None:157        """Test progress_percentage with zero total."""158        job = BibleJob(total_verses=0)159        assert job.progress_percentage == 0.0160161    def test_with_books(self) -> None:162        """Test BibleJob with books list."""163        job = BibleJob(164            books=["john", "matthew", "luke"],165            config_snapshot={"model": "test-model"},166        )167        assert job.books == ["john", "matthew", "luke"]168        assert job.config_snapshot == {"model": "test-model"}169170171class TestBookResult:172    """Tests for BookResult dataclass."""173174    def test_successful_result(self) -> None:175        """Test successful book result."""176        result = BookResult(177            book="john",178            success=True,179            verses_translated=879,180            verses_failed=0,181            duration_seconds=3600.5,182        )183        assert result.book == "john"184        assert result.success is True185        assert result.verses_translated == 879186        assert result.verses_failed == 0187        assert result.duration_seconds == 3600.5188        assert result.error_message is None189190    def test_failed_result(self) -> None:191        """Test failed book result."""192        result = BookResult(193            book="genesis",194            success=False,195            verses_translated=100,196            verses_failed=50,197            duration_seconds=1800.0,198            error_message="Network error",199        )200        assert result.success is False201        assert result.error_message == "Network error"202203204class TestJobResult:205    """Tests for JobResult dataclass."""206207    def test_successful_result(self) -> None:208        """Test successful job result."""209        book_results = [210            BookResult(211                book="john",212                success=True,213                verses_translated=879,214                verses_failed=0,215                duration_seconds=3600.0,216            ),217            BookResult(218                book="matthew",219                success=True,220                verses_translated=1071,221                verses_failed=5,222                duration_seconds=4000.0,223            ),224        ]225        result = JobResult(226            job_id="test-job-123",227            success=True,228            books_completed=2,229            books_failed=0,230            total_verses_translated=1950,231            total_verses_failed=5,232            duration_seconds=7600.0,233            book_results=book_results,234        )235        assert result.job_id == "test-job-123"236        assert result.success is True237        assert result.books_completed == 2238        assert result.books_failed == 0239        assert len(result.book_results) == 2240241242class TestBookConstants:243    """Tests for book constants."""244245    def test_old_testament_count(self) -> None:246        """Test that OT has 39 books."""247        assert len(OLD_TESTAMENT_BOOKS) == 39248249    def test_new_testament_count(self) -> None:250        """Test that NT has 27 books."""251        assert len(NEW_TESTAMENT_BOOKS) == 27252253    def test_all_books_count(self) -> None:254        """Test that all books is 66."""255        assert len(ALL_BOOKS) == 66256257    def test_all_books_is_ot_plus_nt(self) -> None:258        """Test that ALL_BOOKS = OT + NT."""259        assert ALL_BOOKS == OLD_TESTAMENT_BOOKS + NEW_TESTAMENT_BOOKS260261    def test_no_duplicate_books(self) -> None:262        """Test there are no duplicate books."""263        assert len(set(ALL_BOOKS)) == len(ALL_BOOKS)264265    def test_common_ot_books_present(self) -> None:266        """Test that common OT books are present."""267        assert "genesis" in OLD_TESTAMENT_BOOKS268        assert "exodus" in OLD_TESTAMENT_BOOKS269        assert "psalms" in OLD_TESTAMENT_BOOKS270        assert "isaiah" in OLD_TESTAMENT_BOOKS271272    def test_common_nt_books_present(self) -> None:273        """Test that common NT books are present."""274        assert "matthew" in NEW_TESTAMENT_BOOKS275        assert "john" in NEW_TESTAMENT_BOOKS276        assert "acts" in NEW_TESTAMENT_BOOKS277        assert "romans" in NEW_TESTAMENT_BOOKS278        assert "revelation" in NEW_TESTAMENT_BOOKS279