test: update helper PasswordManager mocks

This commit is contained in:
thePR0M3TH3AN
2025-07-14 17:24:08 -04:00
parent 59790543ab
commit 16982f489d
2 changed files with 7 additions and 5 deletions

View File

@@ -12,6 +12,8 @@ from constants import MIN_HEALTHY_RELAYS
def test_background_relay_check_runs_async(monkeypatch):
pm = PasswordManager.__new__(PasswordManager)
pm._current_notification = None
pm._notification_expiry = 0.0
called = {"args": None}
pm.nostr_client = SimpleNamespace(
check_relay_health=lambda min_relays: called.__setitem__("args", min_relays)
@@ -26,6 +28,8 @@ def test_background_relay_check_runs_async(monkeypatch):
def test_background_relay_check_warns_when_unhealthy(monkeypatch):
pm = PasswordManager.__new__(PasswordManager)
pm._current_notification = None
pm._notification_expiry = 0.0
pm.notifications = queue.Queue()
pm.nostr_client = SimpleNamespace(check_relay_health=lambda mr: mr - 1)

View File

@@ -17,6 +17,8 @@ def _make_pm(msg):
return SimpleNamespace(
notifications=q,
get_current_notification=lambda: q.queue[-1] if not q.empty() else None,
_current_notification=None,
_notification_expiry=0.0,
is_dirty=False,
last_update=time.time(),
last_activity=time.time(),
@@ -45,11 +47,7 @@ def test_display_menu_prints_notifications(monkeypatch, capsys):
"clear_header_with_notification",
lambda pm, *a, **k: (
print("HEADER"),
print(
pm.get_current_notification().message
if pm.get_current_notification()
else ""
),
print(main.get_notification_text(pm)),
),
)
monkeypatch.setattr(main, "timed_input", lambda *a, **k: "")