From f8657aca80ced93f1ee904a880fb6ef215649fc6 Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Thu, 9 Apr 2026 19:06:38 +0200 Subject: [PATCH] fix: update tests for chapter_title output and guidance_scale param - epub loader tests: unpack 3 return values (added chapter_title) - generator tests: expect guidance_scale in model.generate() calls Co-Authored-By: Claude Sonnet 4.6 --- tests/test_epub_loader.py | 18 +++++++++--------- tests/test_generator.py | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/test_epub_loader.py b/tests/test_epub_loader.py index 8b1ead5..9850a5d 100644 --- a/tests/test_epub_loader.py +++ b/tests/test_epub_loader.py @@ -58,14 +58,14 @@ def test_input_types_structure(): def test_return_types(): - assert OmniVoiceEpubLoader.RETURN_TYPES == ("STRING", "STRING") - assert OmniVoiceEpubLoader.RETURN_NAMES == ("text", "chapter_list") + assert OmniVoiceEpubLoader.RETURN_TYPES == ("STRING", "STRING", "STRING") + assert OmniVoiceEpubLoader.RETURN_NAMES == ("text", "chapter_title", "chapter_list") def test_chapter_extraction_basic(): epub = make_fake_epub([("Intro", "

Hello world

"), ("Chapter One", "

Body here

")]) with patch('nodes.epub_loader.zipfile.ZipFile', side_effect=epub_opener(epub)): - text, chapter_list = OmniVoiceEpubLoader().load_epub('/fake.epub', 1, 2) + text, chapter_title, chapter_list = OmniVoiceEpubLoader().load_epub('/fake.epub', 1, 2) assert "Hello world" in text assert "Body here" in text assert "---" in text @@ -75,7 +75,7 @@ def test_chapter_extraction_basic(): def test_chapter_range_single(): epub = make_fake_epub([("One", "

First

"), ("Two", "

Second

"), ("Three", "

Third

")]) with patch('nodes.epub_loader.zipfile.ZipFile', side_effect=epub_opener(epub)): - text, _ = OmniVoiceEpubLoader().load_epub('/fake.epub', 2, 2) + text, _, _ = OmniVoiceEpubLoader().load_epub('/fake.epub', 2, 2) assert "Second" in text assert "First" not in text assert "Third" not in text @@ -84,7 +84,7 @@ def test_chapter_range_single(): def test_chapter_list_contains_all(): epub = make_fake_epub([("A", ""), ("B", ""), ("C", "")]) with patch('nodes.epub_loader.zipfile.ZipFile', side_effect=epub_opener(epub)): - _, chapter_list = OmniVoiceEpubLoader().load_epub('/fake.epub', 2, 2) + _, _, chapter_list = OmniVoiceEpubLoader().load_epub('/fake.epub', 2, 2) lines = chapter_list.strip().splitlines() assert len(lines) == 3 assert lines[0].startswith("1.") @@ -94,14 +94,14 @@ def test_chapter_list_contains_all(): def test_range_clamping_high(): epub = make_fake_epub([("A", "

aaa

"), ("B", "

bbb

")]) with patch('nodes.epub_loader.zipfile.ZipFile', side_effect=epub_opener(epub)): - text, _ = OmniVoiceEpubLoader().load_epub('/fake.epub', 1, 99) + text, _, _ = OmniVoiceEpubLoader().load_epub('/fake.epub', 1, 99) assert "aaa" in text and "bbb" in text def test_range_clamping_end_below_start(): epub = make_fake_epub([("A", "

aaa

"), ("B", "

bbb

")]) with patch('nodes.epub_loader.zipfile.ZipFile', side_effect=epub_opener(epub)): - text, _ = OmniVoiceEpubLoader().load_epub('/fake.epub', 2, 1) + text, _, _ = OmniVoiceEpubLoader().load_epub('/fake.epub', 2, 1) assert "bbb" in text assert "aaa" not in text @@ -119,14 +119,14 @@ def test_missing_title_fallback(): z.writestr('OEBPS/ch0.xhtml', '

No title here

') buf.seek(0) with patch('nodes.epub_loader.zipfile.ZipFile', side_effect=epub_opener(buf.read())): - _, chapter_list = OmniVoiceEpubLoader().load_epub('/fake.epub', 1, 1) + _, _, chapter_list = OmniVoiceEpubLoader().load_epub('/fake.epub', 1, 1) assert "1. Chapter 1" in chapter_list def test_script_style_stripped(): epub = make_fake_epub([("Test", '

clean

')]) with patch('nodes.epub_loader.zipfile.ZipFile', side_effect=epub_opener(epub)): - text, _ = OmniVoiceEpubLoader().load_epub('/fake.epub', 1, 1) + text, _, _ = OmniVoiceEpubLoader().load_epub('/fake.epub', 1, 1) assert "alert" not in text assert "color" not in text assert "clean" in text diff --git a/tests/test_generator.py b/tests/test_generator.py index 52ab25e..6fa9451 100644 --- a/tests/test_generator.py +++ b/tests/test_generator.py @@ -46,7 +46,7 @@ def test_generate_auto_voice(): assert "sample_rate" in audio assert audio["sample_rate"] == 24000 mock_model.generate.assert_called_once_with( - text="Hello world", speed=1.0, num_step=32 + text="Hello world", speed=1.0, num_step=32, guidance_scale=2.0 ) @@ -64,7 +64,7 @@ def test_generate_voice_design(): audio = result[0] assert audio["sample_rate"] == 24000 mock_model.generate.assert_called_once_with( - text="Hello world", instruct="female, low pitch", speed=1.0, num_step=32 + text="Hello world", instruct="female, low pitch", speed=1.0, num_step=32, guidance_scale=2.0 )