feat: toggle all-certs view with A key (load_all_certs, Action.TOGGLE_ALL)

This commit is contained in:
Vlad Doloman
2026-06-24 02:36:32 +03:00
parent 629095e0d8
commit 1222fb46a4
3 changed files with 100 additions and 8 deletions

View File

@@ -282,3 +282,44 @@ def test_empty_cert_list_quit():
keys = [ord("q")]
result = _run(keys, certs=[])
assert result.action == Action.EXIT
# ---------------------------------------------------------------------------
# A / a → TOGGLE_ALL
# ---------------------------------------------------------------------------
def test_a_lowercase_returns_toggle_all():
result = _run([ord("a")])
assert result.action == Action.TOGGLE_ALL
def test_A_uppercase_returns_toggle_all():
result = _run([ord("A")])
assert result.action == Action.TOGGLE_ALL
def test_toggle_all_with_no_certs():
"""A works even when the cert list is empty."""
result = _run([ord("a")], certs=[])
assert result.action == Action.TOGGLE_ALL
def test_show_all_flag_passed_through_to_header():
"""show_all=True causes 'ALL certs' to appear in the header addstr call."""
stdscr = _make_stdscr()
stdscr.getch.side_effect = [ord("q")]
with patch("openvpncertupdate.init_colors"):
show_main_screen(stdscr, _CERTS, show_all=True)
# The header addstr call (row 0) should contain 'ALL certs'
calls = [str(c) for c in stdscr.addstr.call_args_list]
assert any("ALL certs" in c for c in calls)
def test_show_all_false_header_shows_expiring():
"""show_all=False (default) shows 'expiring/expired' in the header."""
stdscr = _make_stdscr()
stdscr.getch.side_effect = [ord("q")]
with patch("openvpncertupdate.init_colors"):
show_main_screen(stdscr, _CERTS)
calls = [str(c) for c in stdscr.addstr.call_args_list]
assert any("expiring/expired" in c for c in calls)