aboutsummaryrefslogtreecommitdiff
path: root/app/tests/test_runview.py
diff options
context:
space:
mode:
authorhistoria <historiavg@proton.me>2026-08-26 21:22:40 -0400
committerhistoria <historiavg@proton.me>2026-08-26 21:22:40 -0400
commit477ac3e827e3bdc9f14583fc3aa8db1fa2d27c52 (patch)
tree1e21fa5af1d7a95ffc62fb03eed153056c38ae9e /app/tests/test_runview.py
parent65c6f737f1545ef225768af897acd20f163a4fb4 (diff)
downloadtts-audiobook-generator-477ac3e827e3bdc9f14583fc3aa8db1fa2d27c52.tar.gz
feat: design model support for qwen-tts backend. remove unnecessary port split for qwen models
Diffstat (limited to 'app/tests/test_runview.py')
-rw-r--r--app/tests/test_runview.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/app/tests/test_runview.py b/app/tests/test_runview.py
index 31a8ebe..f2d5180 100644
--- a/app/tests/test_runview.py
+++ b/app/tests/test_runview.py
@@ -363,6 +363,45 @@ class WorkerTests(_FakeTui, unittest.TestCase):
self.assertIn("ERROR - boom", text)
self.assertIn("error", [e["kind"] for e in self._drain(view)])
+ def test_restart_first_stops_then_boots_the_new_model(self):
+ # The managed qwen server hosts another model than this run picked:
+ # the worker stops it (releasing the single port) before booting
+ # the spec again — whose argv now names the newly-selected model.
+ from types import SimpleNamespace
+ spec = SimpleNamespace(name="qwen")
+ events = []
+
+ def fake_start(spec_, progress=None, cancel=None):
+ events.append(("start", progress))
+ progress({"kind": "ready", "name": "qwen",
+ "url": "http://127.0.0.1:7860"})
+ return True
+
+ with patch("audiobook.convert") as mk_convert, \
+ patch.object(runview.servers, "stop") as mk_stop, \
+ patch.object(runview.servers, "start",
+ side_effect=fake_start):
+ view = self.make_view(autostart_spec=spec, restart_first=True,
+ server_name="qwen")
+ view._worker_main()
+ mk_stop.assert_called_once_with("qwen")
+ events = self._drain(view)
+ kinds = [e["kind"] for e in events]
+ self.assertIn("ready", kinds)
+ self.assertNotIn("error", kinds)
+ mk_convert.assert_called_once()
+
+ def test_no_restart_without_the_flag(self):
+ # A plain autostart never stops a server first.
+ from types import SimpleNamespace
+ spec = SimpleNamespace(name="qwen")
+ with patch("audiobook.convert"), \
+ patch.object(runview.servers, "stop") as mk_stop, \
+ patch.object(runview.servers, "start", return_value=True):
+ view = self.make_view(autostart_spec=spec, server_name="qwen")
+ view._worker_main()
+ mk_stop.assert_not_called()
+
if __name__ == "__main__":
unittest.main()