From 0512a932bbf3b87619b6a250f87eb7904d22d1f7 Mon Sep 17 00:00:00 2001 From: historia Date: Mon, 24 Aug 2026 04:53:43 -0400 Subject: feat: hide convert/config/start-stop menus if no valid installation --- app/tests/test_backends.py | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'app/tests/test_backends.py') diff --git a/app/tests/test_backends.py b/app/tests/test_backends.py index c0e8d4a..ac4c8ef 100644 --- a/app/tests/test_backends.py +++ b/app/tests/test_backends.py @@ -99,18 +99,56 @@ class DetectAllTests(unittest.TestCase): self.assertFalse(status.configured) def test_qwen_running_when_either_port_is_up(self): - # Either the CustomVoice port or the Base port counts as running. + # Either the CustomVoice port or the Base port counts as running, + # and the status names which model answered. Probes: CustomVoice + # (QWEN_API_URL) first, then Base (CLONE_API_URL). from backends import qwen with patch.object(qwen, "_is_installed", return_value=False), \ patch("backends.common.server_running", side_effect=[True, False]): status = qwen.detect() self.assertTrue(status.running) + self.assertEqual(status.running_models, ["CustomVoice"]) with patch.object(qwen, "_is_installed", return_value=False), \ patch("backends.common.server_running", side_effect=[False, True]): status = qwen.detect() self.assertTrue(status.running) + self.assertEqual(status.running_models, ["Base"]) + + def test_qwen_running_models_names_both_ports(self): + # Both ports up → both models, Base first (the hub renders + # "running (Base, CustomVoice)"). + from backends import qwen + with patch.object(qwen, "_is_installed", return_value=False), \ + patch("backends.common.server_running", + side_effect=[True, True]): + status = qwen.detect() + self.assertTrue(status.running) + self.assertEqual(status.running_models, ["Base", "CustomVoice"]) + + def test_qwen_detect_marks_our_server_as_managed(self): + from backends import qwen + from backends import servers as servers_mod + with tempfile.TemporaryDirectory() as td: + (Path(td) / "qwen-custom-server.pid").write_text( + "4242", encoding="utf-8") + with patch.object(qwen, "_is_installed", return_value=False), \ + patch("backends.common.server_running", + return_value=False), \ + patch.object(servers_mod, "LOG_DIR", Path(td)), \ + patch.object(servers_mod, "_pid_alive", + return_value=True): + status = qwen.detect() + self.assertTrue(status.managed) + # Without a live pid file the same server counts as remote. + with tempfile.TemporaryDirectory() as td, \ + patch.object(qwen, "_is_installed", return_value=False), \ + patch("backends.common.server_running", + return_value=False), \ + patch.object(servers_mod, "LOG_DIR", Path(td)): + status = qwen.detect() + self.assertFalse(status.managed) def test_faster_status_reflects_install_clone_voices(self): from backends import faster -- cgit v1.2.3