diff options
Diffstat (limited to 'app/tests/test_converter_progress.py')
| -rw-r--r-- | app/tests/test_converter_progress.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/app/tests/test_converter_progress.py b/app/tests/test_converter_progress.py index 1041173..0f708a1 100644 --- a/app/tests/test_converter_progress.py +++ b/app/tests/test_converter_progress.py @@ -142,6 +142,33 @@ class ProgressEventTests(unittest.TestCase): self.assertEqual(events[-1]["kind"], "done") self.assertEqual(events[-1]["ok"], 0) + def test_book_done_reports_output_files(self): + # book_done carries the output file names the run view's summary + # lists after the TUI closes. + events = [] + converter = self.fixture.build(progress=events.append) + converter.run() + done = next(e for e in events if e["kind"] == "book_done") + self.assertEqual(done["files"], ["book_Vivian.mp3"]) + self.assertEqual(converter.current_outputs, ["book_Vivian.mp3"]) + + def test_multi_chapter_book_lists_every_chapter_file(self): + # A multi-section book (no --single-file) produces one file per + # chapter, all reported on the event. + sections = [MagicMock(text=f"chapter {n} text.", title=t) + for n, t in enumerate(("One", "Two"), 1)] + book = MagicMock(title="Book", author="Author", sections=sections) + events = [] + with patch.object(converter_mod.extractors, "extract_book", + return_value=book): + converter = self.fixture.build(progress=events.append) + converter.single_file = False + converter.run() + done = next(e for e in events if e["kind"] == "book_done") + self.assertTrue(done["ok"]) + self.assertEqual(done["files"], + ["book_Vivian_01_One.mp3", "book_Vivian_02_Two.mp3"]) + class CancelTests(unittest.TestCase): def setUp(self): |
