aboutsummaryrefslogtreecommitdiff
path: root/app/tests/test_backends.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/tests/test_backends.py')
-rw-r--r--app/tests/test_backends.py25
1 files changed, 20 insertions, 5 deletions
diff --git a/app/tests/test_backends.py b/app/tests/test_backends.py
index 8ea6a3f..1f146e5 100644
--- a/app/tests/test_backends.py
+++ b/app/tests/test_backends.py
@@ -332,7 +332,9 @@ class QwenUninstallTests(unittest.TestCase):
def test_stops_servers_and_pips(self):
from backends import qwen
- with patch.object(qwen.servers, "stop") as mk_stop, \
+ # Pid files exist for both managed servers, so stop runs.
+ with patch.object(qwen.servers, "pid_for", return_value=1234), \
+ 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")
@@ -342,23 +344,36 @@ class QwenUninstallTests(unittest.TestCase):
# 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_skips_stop_when_no_server_was_started(self):
+ # No pid files: stop() is not called (no "not started by this
+ # tool" noise during an uninstall).
+ from backends import qwen
+ with patch.object(qwen.servers, "pid_for", return_value=None), \
+ patch.object(qwen.servers, "stop") as mk_stop, \
+ patch.object(qwen.common, "pip_uninstall", return_value=0):
+ rc = qwen.uninstall()
+ self.assertEqual(rc, 0)
+ mk_stop.assert_not_called()
+
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, \
+ with patch.object(qwen.servers, "pid_for", return_value=1234), \
+ 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):
+ def test_pip_failure_propagates_the_exit_code(self):
from backends import qwen
- with patch.object(qwen.servers, "stop"), \
+ with patch.object(qwen.servers, "pid_for", return_value=1234), \
+ patch.object(qwen.servers, "stop"), \
patch.object(qwen.common, "pip_uninstall",
return_value=1):
rc = qwen.uninstall()
- self.assertEqual(rc, 0)
+ self.assertEqual(rc, 1)