diff options
| author | historia <historiavg@proton.me> | 2026-08-31 19:45:57 -0400 |
|---|---|---|
| committer | historia <historiavg@proton.me> | 2026-08-31 19:45:57 -0400 |
| commit | 10e72d4960e865acf5346ab8cf518ed5844fe45c (patch) | |
| tree | adf8c10386b9da6280c247f1fed137ef1a514157 /app/tests/test_converter.py | |
| parent | 4bd0282da65db9f118ef5250582ab67079fad538 (diff) | |
| download | tts-audiobook-generator-10e72d4960e865acf5346ab8cf518ed5844fe45c.tar.gz | |
feat: generate a book with all installed models to compare
Diffstat (limited to 'app/tests/test_converter.py')
| -rw-r--r-- | app/tests/test_converter.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/app/tests/test_converter.py b/app/tests/test_converter.py index eaf96ef..41b9cad 100644 --- a/app/tests/test_converter.py +++ b/app/tests/test_converter.py @@ -594,6 +594,45 @@ class PreflightOverwritesTests(unittest.TestCase): self.assertEqual(len(book_files), 1) self.assertEqual(planned, []) + def test_name_tag_inserts_the_model_into_output_names(self): + # "All (multiple generation)" runs plan each model separately: the + # sanitized model id sits between the book stem and the narrator + # tag, so the per-model outputs never collide. + with patch("builtins.input", side_effect=AssertionError("should not prompt")): + book_files, planned = AudiobookConverter.preflight_overwrites( + BACKEND_AUDIOCPP, "Vivian", VOICE_MODE_CUSTOM, None, "mp3", + name_tag="qwen3_tts_1_7b_base_q8_0") + self.assertEqual(planned, + [(book_files[0], + "book_qwen3_tts_1_7b_base_q8_0_Vivian")]) + + def test_name_tag_after_the_stem_collision_suffix(self): + (converter_mod.BOOKS_FOLDER / "book.epub").write_text("x", + encoding="utf-8") + with patch("builtins.input", side_effect=AssertionError("should not prompt")): + book_files, planned = AudiobookConverter.preflight_overwrites( + BACKEND_AUDIOCPP, "Vivian", VOICE_MODE_CUSTOM, None, "mp3", + name_tag="m1") + names = {name for _book, name in planned} + self.assertEqual(names, {"book_txt_m1_Vivian", "book_epub_m1_Vivian"}) + + +class ComputeModelTagTests(unittest.TestCase): + """compute_model_tag: the sanitized model id used in output names.""" + + def test_plain_id_passes_through(self): + self.assertEqual(AudiobookConverter.compute_model_tag( + "qwen3_tts_1_7b_base_q8_0"), "qwen3_tts_1_7b_base_q8_0") + + def test_invalid_characters_and_spaces_become_underscores(self): + self.assertEqual(AudiobookConverter.compute_model_tag( + "model with spaces/colon"), + "model_with_spaces_colon") + + def test_blank_falls_back(self): + self.assertEqual(AudiobookConverter.compute_model_tag(""), "model") + self.assertEqual(AudiobookConverter.compute_model_tag(None), "model") + class RunOverwritePromptTests(unittest.TestCase): """The full run() flow: prompts collected before any conversion starts.""" |
