Add message and notifications to stats screen

This commit is contained in:
thePR0M3TH3AN
2025-07-14 14:40:18 -04:00
parent c7c365e5b9
commit 8413908c94
2 changed files with 51 additions and 0 deletions

View File

@@ -264,11 +264,24 @@ def _display_live_stats(
if not sys.stdin or not sys.stdin.isatty():
clear_screen()
display_fn()
note = drain_notifications(password_manager)
if note:
print(note)
print(colored("Press Enter to continue.", "cyan"))
pause()
return
while True:
clear_screen()
display_fn()
print()
note = drain_notifications(password_manager)
sys.stdout.write("\033[F\033[2K")
if note:
print(note)
else:
print()
print(colored("Press Enter to continue.", "cyan"))
sys.stdout.flush()
try:
user_input = timed_input("", interval)

View File

@@ -0,0 +1,38 @@
import sys
from types import SimpleNamespace
from pathlib import Path
import pytest
sys.path.append(str(Path(__file__).resolve().parents[1]))
import main
def _make_pm():
return SimpleNamespace(display_stats=lambda: print("stats"))
def test_live_stats_shows_message(monkeypatch, capsys):
pm = _make_pm()
monkeypatch.setattr(main, "drain_notifications", lambda *_: None)
monkeypatch.setattr(
main,
"timed_input",
lambda *_: (_ for _ in ()).throw(KeyboardInterrupt()),
)
main._display_live_stats(pm)
out = capsys.readouterr().out
assert "Press Enter to continue." in out
def test_live_stats_shows_notification(monkeypatch, capsys):
pm = _make_pm()
monkeypatch.setattr(main, "drain_notifications", lambda *_: "note")
monkeypatch.setattr(
main,
"timed_input",
lambda *_: (_ for _ in ()).throw(KeyboardInterrupt()),
)
main._display_live_stats(pm)
out = capsys.readouterr().out
assert "note" in out