Merge pull request #361 from PR0M3TH3AN/codex/remove--archive-entry--menu-option

Remove archive entry menu and fix navigation
This commit is contained in:
thePR0M3TH3AN
2025-07-07 14:47:31 -04:00
committed by GitHub
2 changed files with 57 additions and 8 deletions

View File

@@ -683,10 +683,8 @@ def handle_settings(password_manager: PasswordManager) -> None:
choice = input("Select an option or press Enter to go back: ").strip() choice = input("Select an option or press Enter to go back: ").strip()
if choice == "1": if choice == "1":
handle_profiles_menu(password_manager) handle_profiles_menu(password_manager)
pause()
elif choice == "2": elif choice == "2":
handle_nostr_menu(password_manager) handle_nostr_menu(password_manager)
pause()
elif choice == "3": elif choice == "3":
password_manager.change_password() password_manager.change_password()
pause() pause()
@@ -750,8 +748,7 @@ def display_menu(
5. Modify an Existing Entry 5. Modify an Existing Entry
6. 2FA Codes 6. 2FA Codes
7. Settings 7. Settings
8. Archive Entry 8. List Archived
9. List Archived
""" """
display_fn = getattr(password_manager, "display_stats", None) display_fn = getattr(password_manager, "display_stats", None)
if callable(display_fn): if callable(display_fn):
@@ -781,7 +778,7 @@ def display_menu(
print(color_text(menu, "menu")) print(color_text(menu, "menu"))
try: try:
choice = timed_input( choice = timed_input(
"Enter your choice (1-9) or press Enter to exit: ", "Enter your choice (1-8) or press Enter to exit: ",
inactivity_timeout, inactivity_timeout,
).strip() ).strip()
except TimeoutError: except TimeoutError:
@@ -857,9 +854,6 @@ def display_menu(
password_manager.update_activity() password_manager.update_activity()
handle_settings(password_manager) handle_settings(password_manager)
elif choice == "8": elif choice == "8":
password_manager.update_activity()
password_manager.handle_archive_entry()
elif choice == "9":
password_manager.update_activity() password_manager.update_activity()
password_manager.handle_view_archived_entries() password_manager.handle_view_archived_entries()
else: else:

View File

@@ -0,0 +1,55 @@
import time
from types import SimpleNamespace
from pathlib import Path
import sys
import pytest
sys.path.append(str(Path(__file__).resolve().parents[1]))
import main
def _make_pm(calls):
return SimpleNamespace(
is_dirty=False,
last_update=time.time(),
last_activity=time.time(),
nostr_client=SimpleNamespace(close_client_pool=lambda: None),
handle_add_password=lambda: calls.append("add"),
handle_add_totp=lambda: calls.append("totp"),
handle_add_ssh_key=lambda: calls.append("ssh"),
handle_add_seed=lambda: calls.append("seed"),
handle_add_nostr_key=lambda: calls.append("nostr"),
handle_add_pgp=lambda: calls.append("pgp"),
handle_retrieve_entry=lambda: calls.append("retrieve"),
handle_search_entries=lambda: calls.append("search"),
handle_list_entries=lambda: calls.append("list"),
handle_modify_entry=lambda: calls.append("modify"),
handle_display_totp_codes=lambda: calls.append("show_totp"),
handle_view_archived_entries=lambda: calls.append("view_archived"),
update_activity=lambda: None,
lock_vault=lambda: None,
unlock_vault=lambda: None,
)
def test_navigate_all_main_menu_options(monkeypatch):
calls = []
pm = _make_pm(calls)
# Sequence through all main menu options then exit
inputs = iter(["1", "2", "3", "4", "5", "6", "7", "8", ""])
monkeypatch.setattr(main, "timed_input", lambda *_: next(inputs))
# Submenus immediately return
monkeypatch.setattr("builtins.input", lambda *_: "")
monkeypatch.setattr(main, "handle_settings", lambda *_: calls.append("settings"))
with pytest.raises(SystemExit):
main.display_menu(pm, sync_interval=1000, inactivity_timeout=1000)
assert calls == [
"retrieve",
"search",
"list",
"modify",
"show_totp",
"settings",
"view_archived",
]