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_envs.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_envs.py')
| -rw-r--r-- | app/tests/test_backends_envs.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/app/tests/test_backends_envs.py b/app/tests/test_backends_envs.py index bf27f60..82d903a 100644 --- a/app/tests/test_backends_envs.py +++ b/app/tests/test_backends_envs.py @@ -106,6 +106,51 @@ class PipInstallTests(unittest.TestCase): run.assert_not_called() +class PipUninstallTests(unittest.TestCase): + def test_missing_env_is_success_without_running_pip(self): + with patch.object(envs, "env_exists", return_value=False), \ + patch.object(envs.common, "run_console_subprocess") as run: + rc = envs.pip_uninstall(["qwen-tts"]) + self.assertEqual(rc, 0) + run.assert_not_called() + + def test_runs_pip_uninstall_against_the_venv_python(self): + calls = [] + + def fake_run(argv, **kwargs): + calls.append(list(argv)) + return 0 + + with patch.object(envs, "env_exists", return_value=True), \ + patch.object(envs.common, "run_console_subprocess", + side_effect=fake_run): + rc = envs.pip_uninstall(["qwen-tts"]) + self.assertEqual(rc, 0) + # The uninstall targets the venv's python. + self.assertEqual(calls[0][0], str(envs.env_python())) + self.assertIn("uninstall", calls[0]) + self.assertIn("-y", calls[0]) + self.assertIn("qwen-tts", calls[0]) + + def test_streams_to_emit_when_given(self): + with patch.object(envs, "env_exists", return_value=True), \ + patch.object(envs.common, "run_console_subprocess", + return_value=0) as run: + rc = envs.pip_uninstall(["qwen-tts"], emit="EMIT") + self.assertEqual(rc, 0) + # The task view's emit is forwarded so pip never touches the + # terminal behind curses. + self.assertEqual(run.call_args.kwargs.get("emit"), "EMIT") + + def test_console_path_passes_no_emit(self): + with patch.object(envs, "env_exists", return_value=True), \ + patch.object(envs.common, "run_console_subprocess", + return_value=0) as run: + rc = envs.pip_uninstall(["qwen-tts"]) + self.assertEqual(rc, 0) + self.assertIsNone(run.call_args.kwargs.get("emit")) + + class ModuleAvailableTests(unittest.TestCase): def test_false_when_env_missing(self): with patch.object(envs, "env_exists", return_value=False): |
