diff options
Diffstat (limited to 'app/tests/test_converter_progress.py')
| -rw-r--r-- | app/tests/test_converter_progress.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/app/tests/test_converter_progress.py b/app/tests/test_converter_progress.py index d77e9e0..0a44725 100644 --- a/app/tests/test_converter_progress.py +++ b/app/tests/test_converter_progress.py @@ -225,6 +225,24 @@ class CancelTests(unittest.TestCase): converter = self.fixture.build(cancel=threading.Event()) converter._check_cancelled() # no raise + def test_cancel_event_reaches_the_client_before_connect(self): + # The cancel event must be wired into the TTS client at + # construction time — connect-time work (health check, model + # listing, voice validation) is otherwise un-cancellable. + cancel = threading.Event() + cancel.set() + client = MagicMock() + client.cancel = None + with patch.object(converter_mod, "QwenTTSClient", + return_value=client) as mock_qwen: + AudiobookConverter(voice_mode=VOICE_MODE_CUSTOM, + backend=BACKEND_QWEN, voice="Vivian", + cancel=cancel) + self.assertIs(mock_qwen.call_args.kwargs["cancel"], cancel) + with self.assertRaises(ConversionCancelled): + converter_mod.AudiobookConverter._check_cancelled( + MagicMock(tts=None, _cancel=cancel)) + if __name__ == "__main__": unittest.main() |
