diff options
| author | historia <historiavg@proton.me> | 2026-08-25 18:10:08 -0400 |
|---|---|---|
| committer | historia <historiavg@proton.me> | 2026-08-25 18:10:08 -0400 |
| commit | 4b49797b4d57c2d2cf63472636622a7a6280a38e (patch) | |
| tree | e3687c734de5d6159cdad288e025057ed6cd3a16 /app/tests/test_backends.py | |
| parent | bcac6c42eaf9e004716d72960bddefb1db68a93c (diff) | |
| download | tts-audiobook-generator-4b49797b4d57c2d2cf63472636622a7a6280a38e.tar.gz | |
feat: no console drop when uninstalling backends
Diffstat (limited to 'app/tests/test_backends.py')
| -rw-r--r-- | app/tests/test_backends.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/app/tests/test_backends.py b/app/tests/test_backends.py index 0d3be37..8ea6a3f 100644 --- a/app/tests/test_backends.py +++ b/app/tests/test_backends.py @@ -325,3 +325,40 @@ class QwenSetupScreenTests(unittest.TestCase): self.assertIs(mk_steps.call_args[0][0], settings) mk_run.assert_called_once() self.assertEqual(mk_run.call_args[0][2], steps) + + +class QwenUninstallTests(unittest.TestCase): + """qwen.uninstall: stop both servers, then pip-uninstall the package.""" + + def test_stops_servers_and_pips(self): + from backends import qwen + with patch.object(qwen.servers, "stop") as mk_stop, \ + patch.object(qwen.common, "pip_uninstall", + return_value=0) as mk_pip: + rc = qwen.uninstall(emit="EMIT") + self.assertEqual(rc, 0) + self.assertEqual([c.args[0] for c in mk_stop.call_args_list], + ["qwen-custom", "qwen-clone"]) + # The task view's emit is forwarded so pip never touches the terminal. + mk_pip.assert_called_once_with([qwen.QWEN_PIP_PKG], emit="EMIT") + + def test_cancel_before_pip_skips_uninstall(self): + import threading + + from backends import qwen + cancel = threading.Event() + cancel.set() + with patch.object(qwen.servers, "stop") as mk_stop, \ + patch.object(qwen.common, "pip_uninstall") as mk_pip: + rc = qwen.uninstall(cancel=cancel) + self.assertEqual(rc, 130) + self.assertEqual(mk_stop.call_count, 2) + mk_pip.assert_not_called() + + def test_pip_failure_warns_but_still_succeeds(self): + from backends import qwen + with patch.object(qwen.servers, "stop"), \ + patch.object(qwen.common, "pip_uninstall", + return_value=1): + rc = qwen.uninstall() + self.assertEqual(rc, 0) |
