mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-08 23:38:49 +00:00
Pause after displaying entry details
This commit is contained in:
@@ -1792,24 +1792,10 @@ class PasswordManager:
|
|||||||
pause()
|
pause()
|
||||||
|
|
||||||
def show_entry_details_by_index(self, index: int) -> None:
|
def show_entry_details_by_index(self, index: int) -> None:
|
||||||
"""Display entry details using :meth:`handle_retrieve_entry` for the
|
"""Display entry details for ``index`` without prompting."""
|
||||||
given index without prompting for it again."""
|
|
||||||
|
|
||||||
original_input = builtins.input
|
self.display_entry_details(index)
|
||||||
first_call = True
|
pause()
|
||||||
|
|
||||||
def patched_input(prompt: str = "") -> str:
|
|
||||||
nonlocal first_call
|
|
||||||
if first_call:
|
|
||||||
first_call = False
|
|
||||||
return str(index)
|
|
||||||
return original_input(prompt)
|
|
||||||
|
|
||||||
try:
|
|
||||||
builtins.input = patched_input
|
|
||||||
self.handle_retrieve_entry()
|
|
||||||
finally:
|
|
||||||
builtins.input = original_input
|
|
||||||
|
|
||||||
def _prompt_toggle_archive(self, entry: dict, index: int) -> None:
|
def _prompt_toggle_archive(self, entry: dict, index: int) -> None:
|
||||||
"""Prompt the user to archive or restore ``entry`` based on its status."""
|
"""Prompt the user to archive or restore ``entry`` based on its status."""
|
||||||
|
@@ -80,12 +80,12 @@ def test_list_entries_show_details(monkeypatch, capsys):
|
|||||||
lambda *a, **k: "b",
|
lambda *a, **k: "b",
|
||||||
)
|
)
|
||||||
|
|
||||||
inputs = iter(["1", "0", "n"])
|
inputs = iter(["1", "0"])
|
||||||
monkeypatch.setattr("builtins.input", lambda *_: next(inputs))
|
monkeypatch.setattr("builtins.input", lambda *_: next(inputs))
|
||||||
|
|
||||||
pm.handle_list_entries()
|
pm.handle_list_entries()
|
||||||
out = capsys.readouterr().out
|
out = capsys.readouterr().out
|
||||||
assert "Retrieved 2FA Code" in out
|
assert "Label: Example" in out
|
||||||
assert "123456" in out
|
assert "Period: 30s" in out
|
||||||
assert "API" in out
|
assert "API" in out
|
||||||
assert "acct" in out
|
assert "acct" in out
|
||||||
|
@@ -41,11 +41,11 @@ def test_search_entries_prompt_for_details(monkeypatch, capsys):
|
|||||||
monkeypatch.setattr("password_manager.manager.time.sleep", lambda *a, **k: None)
|
monkeypatch.setattr("password_manager.manager.time.sleep", lambda *a, **k: None)
|
||||||
monkeypatch.setattr("password_manager.manager.timed_input", lambda *a, **k: "b")
|
monkeypatch.setattr("password_manager.manager.timed_input", lambda *a, **k: "b")
|
||||||
|
|
||||||
inputs = iter(["Example", "0", "n", ""])
|
inputs = iter(["Example", "0"])
|
||||||
monkeypatch.setattr("builtins.input", lambda *a, **k: next(inputs))
|
monkeypatch.setattr("builtins.input", lambda *a, **k: next(inputs))
|
||||||
|
|
||||||
pm.handle_search_entries()
|
pm.handle_search_entries()
|
||||||
out = capsys.readouterr().out
|
out = capsys.readouterr().out
|
||||||
assert "0. Example" in out
|
assert "0. Example" in out
|
||||||
assert "Retrieved 2FA Code" in out
|
assert "Label: Example" in out
|
||||||
assert "123456" in out
|
assert "Period: 30s" in out
|
||||||
|
Reference in New Issue
Block a user