diff options
| author | historia <historiavg@proton.me> | 2026-08-24 04:53:43 -0400 |
|---|---|---|
| committer | historia <historiavg@proton.me> | 2026-08-24 04:53:43 -0400 |
| commit | 0512a932bbf3b87619b6a250f87eb7904d22d1f7 (patch) | |
| tree | dd2b0eb45823c0690ad2bc86f5aa9be2771f5b17 /app/tests/test_backends.py | |
| parent | 9fb2434dcc8a1ed7bd085b453859d473de64448a (diff) | |
| download | tts-audiobook-generator-0512a932bbf3b87619b6a250f87eb7904d22d1f7.tar.gz | |
feat: hide convert/config/start-stop menus if no valid installation
Diffstat (limited to 'app/tests/test_backends.py')
| -rw-r--r-- | app/tests/test_backends.py | 40 |
1 files changed, 39 insertions, 1 deletions
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 |
