aboutsummaryrefslogtreecommitdiff
path: root/tests/test_converter.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_converter.py')
-rw-r--r--tests/test_converter.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_converter.py b/tests/test_converter.py
index d525c18..e7c0776 100644
--- a/tests/test_converter.py
+++ b/tests/test_converter.py
@@ -258,6 +258,20 @@ class DebugDumpTests(unittest.TestCase):
results = self.converter._synthesize_chunks(["Hello."], debug_dir=blocker / "book")
self.assertEqual(results, {1: audio})
+ def test_failed_chunk_stops_remaining_chunks(self):
+ audio = self._chunk_source("chunk_0001.wav")
+ self.converter.tts.process_chunk_with_retry.side_effect = [audio, None, audio]
+ results = self.converter._synthesize_chunks(["One.", "Two.", "Three."])
+ self.assertEqual(results, {1: audio, 2: None})
+ self.assertEqual(self.converter.tts.process_chunk_with_retry.call_count, 2)
+
+ def test_raising_chunk_stops_remaining_chunks(self):
+ audio = self._chunk_source("chunk_0001.wav")
+ self.converter.tts.process_chunk_with_retry.side_effect = [audio, RuntimeError("boom")]
+ results = self.converter._synthesize_chunks(["One.", "Two.", "Three."])
+ self.assertEqual(results, {1: audio, 2: None})
+ self.assertEqual(self.converter.tts.process_chunk_with_retry.call_count, 2)
+
def test_debug_flag_wiring(self):
with patch("converter.converter.QwenTTSClient"):
self.assertFalse(AudiobookConverter().debug)
@@ -411,6 +425,16 @@ class ServerSideChunkingOutputTests(unittest.TestCase):
self.assertNotIn("single request", out)
self.assertIn("Chapter 2/5 converted (1/1 chunks)", out)
+ def test_partial_chunks_abort_without_assembling(self):
+ converter = self._converter(client_chunks=True)
+ converter.tts.process_chunk_with_retry.side_effect = ["chunk_0001.wav", None]
+ text = " ".join(f"word{i}" for i in range(8))
+ with patch.object(config, "CHUNK_SIZE", 5), \
+ patch.object(converter_mod.audio, "combine_chunks") as mock_combine:
+ ok = converter._convert_text(text, Path("out.mp3"), time.time())
+ self.assertFalse(ok)
+ mock_combine.assert_not_called()
+
class PromptOverwriteTests(unittest.TestCase):
def test_single_file_yes(self):