aboutsummaryrefslogtreecommitdiff
path: root/app/tests/test_backends.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_backends.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_backends.py')
-rw-r--r--app/tests/test_backends.py80
1 files changed, 45 insertions, 35 deletions
diff --git a/app/tests/test_backends.py b/app/tests/test_backends.py
index 99742f3..5cf5633 100644
--- a/app/tests/test_backends.py
+++ b/app/tests/test_backends.py
@@ -119,44 +119,54 @@ class DetectAllTests(unittest.TestCase):
self.assertFalse(status.installed)
self.assertFalse(status.configured)
- def test_qwen_running_when_either_remote_url_is_up(self):
- # Either the CustomVoice or the Base remote URL answering counts as
- # running, and the status names which model answered. Probes: Base
- # (CLONE_REMOTE_URL) first, then CustomVoice (QWEN_REMOTE_URL).
+ def test_qwen_running_when_remote_url_is_up(self):
+ # The single remote URL answering as any of the three demos counts
+ # as running, and the status names which model answered.
from backends import qwen
- with patch.object(qwen, "_is_installed", return_value=False), \
- patch.object(qwen.probe, "identify_server",
- side_effect=[None, "qwen-custom"]):
- status = qwen.detect()
- self.assertTrue(status.running)
- self.assertTrue(status.remote)
- self.assertEqual(status.remote_models, ["CustomVoice"])
- self.assertEqual(status.running_models, ["CustomVoice"])
- with patch.object(qwen, "_is_installed", return_value=False), \
- patch.object(qwen.probe, "identify_server",
- side_effect=["qwen-clone", None]):
- status = qwen.detect()
- self.assertTrue(status.running)
- self.assertEqual(status.remote_models, ["Base"])
- self.assertEqual(status.running_models, ["Base"])
-
- def test_qwen_running_models_names_both_ports(self):
- # Both remote URLs up → both models, Base first (the hub renders
- # "running (Base, CustomVoice)").
+ for identity, model in (("qwen-custom", "CustomVoice"),
+ ("qwen-clone", "Base"),
+ ("qwen-design", "VoiceDesign")):
+ with self.subTest(identity=identity):
+ with patch.object(qwen, "_is_installed", return_value=False), \
+ patch.object(qwen.probe, "identify_server",
+ return_value=identity):
+ status = qwen.detect()
+ self.assertTrue(status.running)
+ self.assertTrue(status.remote)
+ self.assertEqual(status.remote_models, [model])
+ self.assertEqual(status.running_models, [model])
+
+ def test_qwen_detect_uses_one_spec_for_the_configured_model(self):
+ # One demo server hosts one model on the single port: the spec's
+ # argv launches config.QWEN_MODEL's repo, and its identity matches.
from backends import qwen
- with patch.object(qwen, "_is_installed", return_value=False), \
- patch.object(qwen.probe, "identify_server",
- side_effect=["qwen-clone", "qwen-custom"]):
- status = qwen.detect()
- self.assertTrue(status.running)
- self.assertEqual(status.remote_models, ["Base", "CustomVoice"])
- self.assertEqual(status.running_models, ["Base", "CustomVoice"])
+ from backends.probe import (IDENTITY_QWEN_CLONE,
+ IDENTITY_QWEN_CUSTOM,
+ IDENTITY_QWEN_DESIGN)
+ cases = {"CustomVoice": IDENTITY_QWEN_CUSTOM,
+ "Base": IDENTITY_QWEN_CLONE,
+ "VoiceDesign": IDENTITY_QWEN_DESIGN}
+ for model, identity in cases.items():
+ with self.subTest(model=model):
+ with patch.object(qwen.config, "QWEN_MODEL", model), \
+ patch.object(qwen, "_is_installed",
+ return_value=True), \
+ patch("backends.common.server_running",
+ return_value=False):
+ status = qwen.detect()
+ self.assertEqual([spec.name for spec in status.servers],
+ ["qwen"])
+ spec = status.servers[0]
+ self.assertEqual(spec.identity, identity)
+ self.assertIn(qwen.MODEL_REPOS[model], spec.argv)
+ self.assertIn(qwen.MODEL_REPOS[model],
+ status.launch_hint)
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(
+ (Path(td) / "qwen-server.pid").write_text(
"4242", encoding="utf-8")
with patch.object(qwen, "_is_installed", return_value=False), \
patch("backends.common.server_running",
@@ -399,11 +409,11 @@ class QwenSetupScreenTests(unittest.TestCase):
class QwenUninstallTests(unittest.TestCase):
- """qwen.uninstall: stop both servers, then pip-uninstall the package."""
+ """qwen.uninstall: stop the single server, then pip-uninstall the package."""
def test_stops_servers_and_pips(self):
from backends import qwen
- # Pid files exist for both managed servers, so stop runs.
+ # A pid file exists for the managed server, so stop runs.
with patch.object(qwen.servers, "pid_for", return_value=1234), \
patch.object(qwen.servers, "stop") as mk_stop, \
patch.object(qwen.common, "pip_uninstall",
@@ -411,7 +421,7 @@ class QwenUninstallTests(unittest.TestCase):
rc = qwen.uninstall(emit="EMIT")
self.assertEqual(rc, 0)
self.assertEqual([c.args[0] for c in mk_stop.call_args_list],
- ["qwen-custom", "qwen-clone"])
+ ["qwen"])
# The task view's emit is forwarded so pip never touches the terminal.
mk_pip.assert_called_once_with([qwen.QWEN_PIP_PKG], emit="EMIT")
@@ -437,7 +447,7 @@ class QwenUninstallTests(unittest.TestCase):
patch.object(qwen.common, "pip_uninstall") as mk_pip:
rc = qwen.uninstall(cancel=cancel)
self.assertEqual(rc, 130)
- self.assertEqual(mk_stop.call_count, 2)
+ self.assertEqual(mk_stop.call_count, 1)
mk_pip.assert_not_called()
def test_pip_failure_propagates_the_exit_code(self):