diff options
Diffstat (limited to 'app/tests/test_hub.py')
| -rw-r--r-- | app/tests/test_hub.py | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/app/tests/test_hub.py b/app/tests/test_hub.py index 44c63fd..439be26 100644 --- a/app/tests/test_hub.py +++ b/app/tests/test_hub.py @@ -520,6 +520,83 @@ class SubmenuStatusTableTests(unittest.TestCase): self.assertEqual(self._labels(captured["options"]), ["Configure audio.cpp", "Uninstall Backend"]) + def test_configure_menu_offers_qwens_per_model_manager(self): + # qwen ships a dedicated configure screen (per-model weight + # installs): once installed, "Configure qwen-tts" appears in the + # flat action list. + captured = {} + infos = [BackendInfo("qwen", "qwen-tts", lambda: None, lambda: 0, + uninstall=lambda **kwargs: 0, + configure_screen=lambda scr: 0)] + statuses = [BackendStatus("qwen", "qwen-tts", installed=True, + configured=True)] + with patch.object(hub, "REGISTRY", infos), \ + patch.object(hub, "detect_all", return_value=statuses), \ + patch.object(hub.tui, "menu", + self._capture_menu(captured)), \ + patch.object(hub.shutil, "which", + return_value="/usr/bin/ffmpeg"): + result = hub._Hub(None).screen_configure() + self.assertIs(result, tui.Wizard.BACK) + self.assertEqual(self._labels(captured["options"]), + ["Configure qwen-tts", "Uninstall Backend"]) + self.assertEqual(captured["table_rows"], + [("qwen-tts", "installed", "warn", "body")]) + + def test_selecting_qwen_runs_its_configure_screen_not_setup(self): + ran = [] + invalidated = [] + + def configure(scr): + ran.append("configure") + return 0 + + def setup(scr): + ran.append("setup") + return 0 + + info = BackendInfo("qwen", "qwen-tts", lambda: None, setup, + uninstall=lambda **kwargs: 0, + configure_screen=configure) + + def first_pick(stdscr, title, options, **kwargs): + return ("configure", "qwen") + + statuses = [BackendStatus("qwen", "qwen-tts", installed=True, + configured=True)] + with patch.object(hub, "REGISTRY", [info]), \ + patch.object(hub, "get", return_value=info), \ + patch.object(hub, "detect_all", return_value=statuses), \ + patch.object(hub.tui, "menu", first_pick), \ + patch.object(hub, "invalidate_detect_cache", + side_effect=lambda: invalidated.append(True)), \ + patch.object(hub.shutil, "which", return_value="/x"): + leaf = hub._Hub(None).screen_configure() + # The selection pushes the backend's configure screen as one + # leaf of the wizard stack (which invalidates the status + # cache when it finishes). + self.assertIs(leaf(), tui.Wizard.BACK) + self.assertEqual(ran, ["configure"]) + self.assertEqual(invalidated, [True]) + + def test_bare_qwen_without_configure_screen_still_has_no_entry(self): + # Without a dedicated configure screen, plain qwen stays excluded + # from Configure backends (its wizard asks nothing to configure). + captured = {} + infos = [BackendInfo("qwen", "qwen-tts", lambda: None, lambda: 0, + uninstall=lambda **kwargs: 0)] + statuses = [BackendStatus("qwen", "qwen-tts", installed=True, + configured=True)] + with patch.object(hub, "REGISTRY", infos), \ + patch.object(hub, "detect_all", return_value=statuses), \ + patch.object(hub.tui, "menu", + self._capture_menu(captured)), \ + patch.object(hub.shutil, "which", return_value="/x"): + result = hub._Hub(None).screen_configure() + self.assertIs(result, tui.Wizard.BACK) + self.assertEqual(self._labels(captured["options"]), + ["Uninstall Backend"]) + def test_convert_menu_builds_one_form_with_backend_field(self): captured = {} st = BackendStatus("qwen", "qwen-tts", installed=True, |
