diff options
Diffstat (limited to 'app/tests/test_hub.py')
| -rw-r--r-- | app/tests/test_hub.py | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/app/tests/test_hub.py b/app/tests/test_hub.py index 68d0f34..9842148 100644 --- a/app/tests/test_hub.py +++ b/app/tests/test_hub.py @@ -323,7 +323,8 @@ class SubmenuStatusTableTests(unittest.TestCase): """First picker screen of every flow repeats the backend status table. Entries themselves stay clean: the configure-backends menu lists flat - actions, and the Start/Stop menu offers only installed backends. + actions, and the Start/Stop menu offers only installed backends' + servers, showing running/stopped inline instead of the table. """ def _capture_menu(self, captured): @@ -580,25 +581,30 @@ class SubmenuStatusTableTests(unittest.TestCase): def test_server_menu_lists_only_installed_backends(self): captured = {} installed = BackendStatus("audiocpp", "audio.cpp", installed=True, - configured=True) + configured=True, + servers=[ServerSpec("audiocpp", "http://127.0.0.1:8080", [])]) remote = BackendStatus("qwen", "qwen-tts", installed=False, configured=False, running=True) gone = BackendStatus("faster", "faster-qwen3-tts", installed=False, configured=False) with patch.object(hub.tui, "menu", self._capture_menu(captured)), \ + patch.object(hub.common, "server_running", + return_value=False), \ patch.object(hub, "detect_all", return_value=[installed, remote, gone]), \ patch.object(hub.shutil, "which", return_value="/x"): result = hub._Hub(None).screen_server() self.assertIs(result, tui.Wizard.BACK) - # Only the installed backend is offered; a running external server - # (remote) can't be stopped from here and must not appear. - self.assertEqual([label for label, _ in captured["options"]], + # Only the installed backend's server is offered; a running external + # server (remote) can't be stopped from here and must not appear. + self.assertEqual([opt[0] for opt in captured["options"]], ["audio.cpp"]) - # The status table still shows all three, states included. - self.assertEqual([row[0] for row in captured["table_rows"]], - ["audio.cpp", "qwen-tts", "faster-qwen3-tts"]) + # The running/stopped state lives in the status table above the + # menu (not on the entries, whose colors the selection bar covers). + self.assertEqual(captured["table_title"], "Server status") + self.assertEqual(captured["table_rows"], + [("audio.cpp", "stopped", "err", "body")]) def test_server_menu_flashes_when_nothing_installed(self): flashed = [] @@ -1961,17 +1967,29 @@ class HubNavigationTests(unittest.TestCase): status = BackendStatus("qwen", "qwen-tts", installed=True, configured=True, servers=specs) registry = [self._info("qwen", "qwen-tts")] - with patch.object(hub.common, "server_running", return_value=False): - titles = self._drive( - ["server", "qwen", "qwen-clone", tui.Wizard.BACK, - tui.Wizard.BACK, tui.Wizard.BACK, tui.Wizard.BACK], - [status], registry) + titles = [] + script = ["server", specs[0], tui.Wizard.BACK, tui.Wizard.BACK] + + def menu(stdscr, title, options, **kwargs): + titles.append(title) + return script.pop(0) + + with patch.object(hub, "REGISTRY", registry), \ + patch.object(hub, "detect_all", return_value=[status]), \ + patch.object(hub.tui, "menu", menu), \ + patch.object(hub.common, "server_running", + return_value=False), \ + patch.object(hub.taskview, "run_steps", return_value=0), \ + patch.object(hub.tui, "flash", lambda *a, **k: None), \ + patch.object(hub.audiocpp_backend, "find_local_checkout", + return_value=None): + hub._Hub(None).run() + # Selecting a server toggles it directly (no action sub-menu), then + # Esc steps back one screen at a time to the server list and main. self.assertEqual( titles, ["tts-audiobook-generator", "Start / Stop a server", - "qwen-tts server", "qwen-clone (stopped)", - "qwen-tts server", "Start / Stop a server", - "tts-audiobook-generator"]) + "Start / Stop a server", "tts-audiobook-generator"]) def test_esc_on_main_menu_quits(self): titles = self._drive([tui.Wizard.BACK], [], []) |
