aboutsummaryrefslogtreecommitdiff
path: root/app/tests/test_hub.py
diff options
context:
space:
mode:
authorhistoria <historiavg@proton.me>2026-09-02 18:36:34 -0400
committerhistoria <historiavg@proton.me>2026-09-02 18:36:34 -0400
commit268b6734b22cc251bf340882ea9debbd079b9a48 (patch)
tree41dcfb983af96e5a3ad95a83d81298f3587f588c /app/tests/test_hub.py
parentf14b80f6b42a0d0891718eb6284336b1694795cf (diff)
downloadtts-audiobook-generator-268b6734b22cc251bf340882ea9debbd079b9a48.tar.gz
rename generator to tts-audiobook-generator. remove pointless upgrade flashes.
Diffstat (limited to 'app/tests/test_hub.py')
-rw-r--r--app/tests/test_hub.py55
1 files changed, 23 insertions, 32 deletions
diff --git a/app/tests/test_hub.py b/app/tests/test_hub.py
index 228a103..8d5edd9 100644
--- a/app/tests/test_hub.py
+++ b/app/tests/test_hub.py
@@ -396,7 +396,8 @@ class SubmenuStatusTableTests(unittest.TestCase):
def setUp(self):
# These tests concern the backend actions; the host's git-checkout
- # state (which gates the "Update Generator" entry) must not leak in.
+ # state (which gates the "Update tts-audiobook-generator" entry)
+ # must not leak in.
patcher = patch.object(hub.selfupdate, "is_git_checkout",
return_value=False)
patcher.start()
@@ -4049,7 +4050,7 @@ class ConfigureBackendsDispatchTests(unittest.TestCase):
self.assertEqual(flashes[-1][1], "err")
self.assertIn("did not complete", flashes[-1][0])
- def test_update_backends_action_flashes_warn_when_cancelled(self):
+ def test_update_backends_action_silent_when_cancelled(self):
infos = [BackendInfo("qwen", "qwen-tts", lambda: None, lambda: 0,
update=lambda **kw: 0)]
statuses = [BackendStatus("qwen", "qwen-tts", installed=True,
@@ -4057,11 +4058,14 @@ class ConfigureBackendsDispatchTests(unittest.TestCase):
patch_flash, flashes = self._capture_flashes()
with patch.object(hub, "REGISTRY", infos), \
patch.object(hub, "detect_all", return_value=statuses), \
- patch.object(hub.taskview, "run_steps", return_value=130), \
+ patch.object(hub.taskview, "run_steps",
+ return_value=130) as mk_run, \
patch_flash:
hub._update_backends_action(None)
- self.assertEqual(flashes[-1][1], "warn")
- self.assertIn("cancelled", flashes[-1][0])
+ # The task view already showed "cancelled" and waited for a key,
+ # so the hub adds no flash on top of it.
+ mk_run.assert_called_once()
+ self.assertEqual(flashes, [])
def test_update_backends_action_without_targets_flashes_a_hint(self):
# An installed backend without an update action (and nothing else
@@ -4129,8 +4133,8 @@ class ConfigureBackendsDispatchTests(unittest.TestCase):
hub._Hub(None).screen_configure()
return [opt[0] for opt in captured["options"]]
- self.assertIn("Update Generator", options_for(True))
- self.assertNotIn("Update Generator", options_for(False))
+ self.assertIn("Update tts-audiobook-generator", options_for(True))
+ self.assertNotIn("Update tts-audiobook-generator", options_for(False))
def test_selecting_update_generator_runs_the_action_and_reshows(self):
titles = []
@@ -4170,8 +4174,6 @@ class ConfigureBackendsDispatchTests(unittest.TestCase):
patch_flash, flashes = self._capture_flashes()
with patch.object(hub.selfupdate, "is_git_checkout",
return_value=True), \
- patch.object(hub.selfupdate, "current_commit",
- return_value="aaa"), \
patch.object(hub.selfupdate, "modified_tracked_files",
return_value=["app/converter/config.py"]), \
patch.object(hub.tui, "confirm",
@@ -4185,12 +4187,10 @@ class ConfigureBackendsDispatchTests(unittest.TestCase):
body = mk_confirm.call_args[1]["body"]
self.assertIn("app/converter/config.py", body)
- def test_update_self_action_runs_step_and_flashes_update(self):
+ def test_update_self_action_runs_step_silently_on_success(self):
patch_flash, flashes = self._capture_flashes()
with patch.object(hub.selfupdate, "is_git_checkout",
return_value=True), \
- patch.object(hub.selfupdate, "current_commit",
- side_effect=["aaa", "bbb"]), \
patch.object(hub.selfupdate, "modified_tracked_files",
return_value=[]), \
patch.object(hub.taskview, "run_steps",
@@ -4201,7 +4201,8 @@ class ConfigureBackendsDispatchTests(unittest.TestCase):
hub._update_self_action(None)
mk_run.assert_called_once()
self.assertEqual(mk_run.call_args[0][0], None)
- self.assertEqual(mk_run.call_args[0][1], "Update Generator")
+ self.assertEqual(mk_run.call_args[0][1],
+ "Update tts-audiobook-generator")
steps = mk_run.call_args[0][2]
self.assertEqual([step.title for step in steps],
["Fetch and reset the checkout"])
@@ -4211,48 +4212,38 @@ class ConfigureBackendsDispatchTests(unittest.TestCase):
steps[0].work(emit, "CANCEL")
mk_update.assert_called_once_with(emit=emit, cancel="CANCEL")
- self.assertEqual(len(flashes), 1)
- text, kind = flashes[0]
- self.assertEqual(kind, "ok")
- self.assertIn("aaa", text)
- self.assertIn("bbb", text)
- self.assertIn("Restart to apply", text)
+ # The task view already showed "completed" and waited for a key;
+ # the restart reminder lives in the run's console output.
+ self.assertEqual(flashes, [])
- def test_update_self_action_flashes_already_up_to_date(self):
+ def test_update_self_action_silent_when_already_up_to_date(self):
patch_flash, flashes = self._capture_flashes()
with patch.object(hub.selfupdate, "is_git_checkout",
return_value=True), \
- patch.object(hub.selfupdate, "current_commit",
- side_effect=["aaa", "aaa"]), \
patch.object(hub.selfupdate, "modified_tracked_files",
return_value=[]), \
patch.object(hub.taskview, "run_steps", return_value=0), \
patch_flash:
hub._update_self_action(None)
- self.assertEqual(flashes,
- [("The generator is already up to date (aaa).",
- "ok")])
+ # The console already said so; no flash after the key press.
+ self.assertEqual(flashes, [])
- def test_update_self_action_flashes_warn_when_cancelled(self):
+ def test_update_self_action_silent_when_cancelled(self):
patch_flash, flashes = self._capture_flashes()
with patch.object(hub.selfupdate, "is_git_checkout",
return_value=True), \
- patch.object(hub.selfupdate, "current_commit",
- side_effect=["aaa", "aaa"]), \
patch.object(hub.selfupdate, "modified_tracked_files",
return_value=[]), \
patch.object(hub.taskview, "run_steps", return_value=130), \
patch_flash:
hub._update_self_action(None)
- self.assertEqual(flashes[-1][1], "warn")
- self.assertIn("cancelled", flashes[-1][0])
+ # The task view already showed "cancelled" and waited for a key.
+ self.assertEqual(flashes, [])
def test_update_self_action_flashes_err_when_failed(self):
patch_flash, flashes = self._capture_flashes()
with patch.object(hub.selfupdate, "is_git_checkout",
return_value=True), \
- patch.object(hub.selfupdate, "current_commit",
- side_effect=["aaa", "aaa"]), \
patch.object(hub.selfupdate, "modified_tracked_files",
return_value=[]), \
patch.object(hub.taskview, "run_steps", return_value=1), \