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

OPEN SOURCE

software/tests/test_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_models.py189 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 d15f1c858925c394426ab21846851cccd2fb99c96997703051b04826faf12c49
1"""Tests for data models."""23import pytest4from datetime import datetime56from src.models.verse import (7    BookMetadata,8    ChapterSummary,9    GlossaryTerm,10    TranslationContext,11    TranslationOutput,12    Verse,13    VerseReference,14)151617class TestVerseReference:18    """Tests for VerseReference model."""1920    def test_create_verse_reference(self) -> None:21        """Test creating a verse reference."""22        ref = VerseReference(book="john", chapter=1, verse=1)23        assert ref.book == "john"24        assert ref.chapter == 125        assert ref.verse == 12627    def test_verse_reference_str(self) -> None:28        """Test string representation."""29        ref = VerseReference(book="john", chapter=3, verse=16)30        assert str(ref) == "john:3:16"3132    def test_verse_reference_from_string(self) -> None:33        """Test parsing from string."""34        ref = VerseReference.from_string("john:1:1")35        assert ref.book == "john"36        assert ref.chapter == 137        assert ref.verse == 13839    def test_verse_reference_from_string_uppercase(self) -> None:40        """Test parsing handles case insensitivity."""41        ref = VerseReference.from_string("JOHN:1:1")42        assert ref.book == "john"4344    def test_verse_reference_invalid_format(self) -> None:45        """Test parsing invalid format raises error."""46        with pytest.raises(ValueError, match="Invalid verse reference"):47            VerseReference.from_string("john:1")4849    def test_verse_reference_invalid_format_too_many_parts(self) -> None:50        """Test parsing invalid format with too many parts."""51        with pytest.raises(ValueError, match="Invalid verse reference"):52            VerseReference.from_string("john:1:1:extra")535455class TestVerse:56    """Tests for Verse model."""5758    def test_create_verse(self) -> None:59        """Test creating a verse."""60        ref = VerseReference(book="john", chapter=1, verse=1)61        verse = Verse(reference=ref, greek_text="Ἐν ἀρχῇ")62        assert verse.reference == ref63        assert verse.greek_text == "Ἐν ἀρχῇ"6465    def test_verse_has_source_text_with_greek(self) -> None:66        """Test has_source_text with Greek text."""67        ref = VerseReference(book="john", chapter=1, verse=1)68        verse = Verse(reference=ref, greek_text="Ἐν ἀρχῇ")69        assert verse.has_source_text() is True7071    def test_verse_has_source_text_with_hebrew(self) -> None:72        """Test has_source_text with Hebrew text."""73        ref = VerseReference(book="genesis", chapter=1, verse=1)74        verse = Verse(reference=ref, hebrew_text="בְּרֵאשִׁית")75        assert verse.has_source_text() is True7677    def test_verse_has_source_text_empty(self) -> None:78        """Test has_source_text with no source text."""79        ref = VerseReference(book="john", chapter=1, verse=1)80        verse = Verse(reference=ref, english_kjv="In the beginning")81        assert verse.has_source_text() is False828384class TestGlossaryTerm:85    """Tests for GlossaryTerm model."""8687    def test_create_glossary_term(self) -> None:88        """Test creating a glossary term."""89        term = GlossaryTerm(90            original="λόγος",91            transliteration="logos",92            japanese="言葉",93            english="word",94            notes="Used in John 1:1",95        )96        assert term.original == "λόγος"97        assert term.transliteration == "logos"98        assert term.japanese == "言葉"99        assert term.english == "word"100        assert term.notes == "Used in John 1:1"101102    def test_create_glossary_term_without_notes(self) -> None:103        """Test creating a glossary term without notes."""104        term = GlossaryTerm(105            original="ἀγάπη",106            transliteration="agape",107            japanese="愛",108            english="love",109        )110        assert term.notes is None111112113class TestBookMetadata:114    """Tests for BookMetadata model."""115116    def test_create_book_metadata(self) -> None:117        """Test creating book metadata."""118        meta = BookMetadata(119            book="john",120            name_japanese="ヨハネによる福音書",121            name_english="Gospel of John",122            testament="NT",123            author="John the Apostle",124            themes=["love", "light", "life"],125            description="The fourth Gospel",126            chapter_count=21,127            verse_count=879,128        )129        assert meta.book == "john"130        assert meta.name_japanese == "ヨハネによる福音書"131        assert len(meta.themes) == 3132133134class TestChapterSummary:135    """Tests for ChapterSummary model."""136137    def test_create_chapter_summary(self) -> None:138        """Test creating chapter summary."""139        summary = ChapterSummary(140            book="john",141            chapter=1,142            summary="The prologue introduces Jesus as the Word.",143            key_events=["Word becomes flesh"],144            key_characters=["Jesus", "John the Baptist"],145            key_themes=["Light", "Word"],146        )147        assert summary.book == "john"148        assert summary.chapter == 1149150151class TestTranslationContext:152    """Tests for TranslationContext model."""153154    def test_create_translation_context(self) -> None:155        """Test creating translation context."""156        ref = VerseReference(book="john", chapter=1, verse=1)157        verse = Verse(reference=ref, greek_text="Ἐν ἀρχῇ")158        context = TranslationContext(target_verse=verse)159        assert context.target_verse == verse160        assert context.preceding_verses == []161        assert context.following_verses == []162163164class TestTranslationOutput:165    """Tests for TranslationOutput model."""166167    def test_create_translation_output(self) -> None:168        """Test creating translation output."""169        ref = VerseReference(book="john", chapter=1, verse=1)170        output = TranslationOutput(171            reference=ref,172            text="初めに言葉があった。",173            model="claude-sonnet-4-20250514",174        )175        assert output.reference == ref176        assert output.text == "初めに言葉があった。"177        assert output.model == "claude-sonnet-4-20250514"178        assert output.prompt_version == "v1.0"179180    def test_translation_output_with_timestamp(self) -> None:181        """Test translation output has timestamp."""182        ref = VerseReference(book="john", chapter=1, verse=1)183        output = TranslationOutput(184            reference=ref,185            text="初めに言葉があった。",186            model="claude-sonnet-4-20250514",187        )188        assert isinstance(output.timestamp, datetime)189