From 471798cf5e967b2d1bceb02d12a47fe9ad1cbed1 Mon Sep 17 00:00:00 2001 From: historia Date: Mon, 24 Aug 2026 03:22:29 -0400 Subject: feat: tui ffmpeg check --- app/tests/test_hub.py | 31 +++++++++++++++++++++++++++++++ app/tests/test_tui.py | 19 +++++++++++++++++++ 2 files changed, 50 insertions(+) (limited to 'app/tests') diff --git a/app/tests/test_hub.py b/app/tests/test_hub.py index b3a17e8..749d2e6 100644 --- a/app/tests/test_hub.py +++ b/app/tests/test_hub.py @@ -160,6 +160,37 @@ class HubMenuTests(unittest.TestCase): ["Convert books...", "Set up a backend...", "Configure a backend...", "Server...", "Settings...", "Quit"]) + def test_ffmpeg_warning_shown_when_missing(self): + # ffmpeg not on PATH → a red notice is passed above the table. + captured = {} + + def fake_menu(stdscr, title, options, **kwargs): + captured["notice_lines"] = kwargs.get("notice_lines") + return "quit" + + screen = FakeScreen() + with patch.object(hub.tui, "menu", fake_menu), \ + patch.object(hub, "detect_all", return_value=[]), \ + patch.object(hub.shutil, "which", return_value=None): + hub._hub_menu(screen) + self.assertEqual(captured["notice_lines"], + [("Warning: ffmpeg not installed!", "err")]) + + def test_ffmpeg_warning_hidden_when_installed(self): + # ffmpeg on PATH → no notice is passed at all. + captured = {} + + def fake_menu(stdscr, title, options, **kwargs): + captured["notice_lines"] = kwargs.get("notice_lines") + return "quit" + + screen = FakeScreen() + with patch.object(hub.tui, "menu", fake_menu), \ + patch.object(hub, "detect_all", return_value=[]), \ + patch.object(hub.shutil, "which", return_value="/usr/bin/ffmpeg"): + hub._hub_menu(screen) + self.assertIsNone(captured["notice_lines"]) + def test_convert_with_no_available_backend_offers_setup(self): # One installed-but-not-ready backend → Convert is offered. The # convert menu lists no available backend, so only "Set up a diff --git a/app/tests/test_tui.py b/app/tests/test_tui.py index c121d55..c87374f 100644 --- a/app/tests/test_tui.py +++ b/app/tests/test_tui.py @@ -300,6 +300,25 @@ class MenuTableTests(TuiTestCase): table_title="Backend status", table_rows=self.ROWS) self.assert_inside_border(screen) + def test_notice_line_is_red_and_above_the_table(self): + screen = FakeScreen(keys=[10]) + tui.menu(screen, "Hub", [("Quit", "quit")], + table_title="Backend status", table_rows=self.ROWS, + notice_lines=[("Warning: ffmpeg not installed!", "err")]) + x0, _ = self.dialog_box(screen) + margin = x0 + 1 + tui.Frame.LIST_MARGIN + x, attr = next((x, a) for _, x, text, a in screen.strings + if text == "Warning: ffmpeg not installed!") + self.assertEqual(x, margin) + self.assertEqual(attr, tui._THEME["err"]) + # The notice sits above the table title ("Backend status"). + notice_y = next(y for y, _, text, _ in screen.strings + if text == "Warning: ffmpeg not installed!") + title_y = next(y for y, _, text, _ in screen.strings + if text == "Backend status") + self.assertLess(notice_y, title_y) + self.assert_inside_border(screen) + class ConfirmTests(TuiTestCase): def test_tab_switches_and_enter_activates(self): -- cgit v1.2.3