aboutsummaryrefslogtreecommitdiff
path: root/app/tests/test_hub.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/tests/test_hub.py')
-rw-r--r--app/tests/test_hub.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/app/tests/test_hub.py b/app/tests/test_hub.py
index e38acbe..84796ee 100644
--- a/app/tests/test_hub.py
+++ b/app/tests/test_hub.py
@@ -2661,6 +2661,8 @@ class ConvertFlowTests(unittest.TestCase):
self._mock_preflight()
self._answer_form(backend="sglomni", model_id=entry.key,
voice=str(ref), instructions="")
+ # Higgs's chunk-cap popup: keep the configured chunk size.
+ self.tui.script.append("anyway")
cmd = self._convert(None, [self._ready("sglomni",
"SGLang-Omni")])
fields = self.tui.forms_seen[-1][1]
@@ -2691,6 +2693,8 @@ class ConvertFlowTests(unittest.TestCase):
self._mock_preflight()
self._answer_form(backend="sglomni", model_id=entry.key,
voice="", instructions="")
+ # Higgs's chunk-cap popup: keep the configured chunk size.
+ self.tui.script.append("anyway")
cmd = self._convert(None, [self._ready("sglomni",
"SGLang-Omni")])
kwargs = cmd[2]
@@ -2738,6 +2742,8 @@ class ConvertFlowTests(unittest.TestCase):
self._answer_form(backend="sglomni-remote",
model_id="higgs_audio_v3_tts",
voice="narrator", instructions="")
+ # Higgs's chunk-cap popup: keep the configured chunk size.
+ self.tui.script.append("anyway")
cmd = self._convert(
None, [self._remote("sglomni", "SGLang-Omni",
url="http://sgl.local:8100")])
@@ -2870,6 +2876,10 @@ class ConvertFlowTests(unittest.TestCase):
else: # design
overrides["instructions"] = "A warm narrator."
self._answer_form(**overrides)
+ if hub.converter_mod.chunk_clamp_needed(entry):
+ # Higgs's chunk-cap popup: keep the configured
+ # chunk size.
+ self.tui.script.append("anyway")
cmd = self._convert(None, [
self._ready("sglomni", "SGLang-Omni")])
self.assertIsNotNone(cmd)
@@ -3196,6 +3206,54 @@ class PreflightTests(unittest.TestCase):
with self.assertRaises(hub._BackToForm):
confirm("overwrite?", True)
+ # -- sglomni: the chunk-cap popup ------------------------------------
+
+ def _sglomni_cmd(self, model_id="higgs_audio_v3_tts"):
+ return ("convert", "sglomni",
+ {"model_id": model_id, "clone": None, "output_format": "mp3"})
+
+ def _run_sglomni_preflight(self, cmd, menu_answer):
+ stdscr = object()
+ with patch.object(hub.AudiobookConverter, "preflight_overwrites",
+ return_value=(["book.txt"], [("book.txt", "x")])), \
+ patch.object(hub.tui, "menu", return_value=menu_answer) \
+ as mk_menu:
+ outcome = hub._preflight(stdscr, cmd)
+ return outcome, mk_menu
+
+ def test_sglomni_run_asks_the_chunk_popup_and_stashes_the_clamp(self):
+ cmd = self._sglomni_cmd()
+ outcome, mk_menu = self._run_sglomni_preflight(cmd, "clamp")
+ self.assertTrue(outcome)
+ self.assertEqual(cmd[2]["chunk_size"], 80)
+ options = mk_menu.call_args[0][2]
+ self.assertEqual([value for _label, value in options],
+ ["clamp", "anyway", "cancel"])
+ self.assertIn("Set Chunk to 80", options[0][0])
+
+ def test_sglomni_run_try_anyway_stashes_no_clamp(self):
+ cmd = self._sglomni_cmd()
+ outcome, mk_menu = self._run_sglomni_preflight(cmd, "anyway")
+ self.assertTrue(outcome)
+ self.assertNotIn("chunk_size", cmd[2])
+ mk_menu.assert_called_once()
+
+ def test_sglomni_run_cancel_raises_back_to_form(self):
+ # Cancel backs out to the Generate form (the run never starts).
+ stdscr = object()
+ with patch.object(hub.AudiobookConverter, "preflight_overwrites",
+ return_value=(["book.txt"], [("book.txt", "x")])), \
+ patch.object(hub.tui, "menu", return_value="cancel"):
+ with self.assertRaises(hub._BackToForm):
+ hub._preflight(stdscr, self._sglomni_cmd())
+
+ def test_sglomni_uncapped_model_skips_the_popup(self):
+ outcome, mk_menu = self._run_sglomni_preflight(
+ self._sglomni_cmd("zonos2"),
+ MagicMock(side_effect=AssertionError("should not ask")))
+ self.assertTrue(outcome)
+ mk_menu.assert_not_called()
+
# -- "All (multiple generation)": one plan per model ----------------
def _all_cmd(self):