mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-09 15:58:48 +00:00
test: update helper PasswordManager mocks
This commit is contained in:
@@ -12,6 +12,8 @@ from constants import MIN_HEALTHY_RELAYS
|
|||||||
|
|
||||||
def test_background_relay_check_runs_async(monkeypatch):
|
def test_background_relay_check_runs_async(monkeypatch):
|
||||||
pm = PasswordManager.__new__(PasswordManager)
|
pm = PasswordManager.__new__(PasswordManager)
|
||||||
|
pm._current_notification = None
|
||||||
|
pm._notification_expiry = 0.0
|
||||||
called = {"args": None}
|
called = {"args": None}
|
||||||
pm.nostr_client = SimpleNamespace(
|
pm.nostr_client = SimpleNamespace(
|
||||||
check_relay_health=lambda min_relays: called.__setitem__("args", min_relays)
|
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):
|
def test_background_relay_check_warns_when_unhealthy(monkeypatch):
|
||||||
pm = PasswordManager.__new__(PasswordManager)
|
pm = PasswordManager.__new__(PasswordManager)
|
||||||
|
pm._current_notification = None
|
||||||
|
pm._notification_expiry = 0.0
|
||||||
pm.notifications = queue.Queue()
|
pm.notifications = queue.Queue()
|
||||||
pm.nostr_client = SimpleNamespace(check_relay_health=lambda mr: mr - 1)
|
pm.nostr_client = SimpleNamespace(check_relay_health=lambda mr: mr - 1)
|
||||||
|
|
||||||
|
@@ -17,6 +17,8 @@ def _make_pm(msg):
|
|||||||
return SimpleNamespace(
|
return SimpleNamespace(
|
||||||
notifications=q,
|
notifications=q,
|
||||||
get_current_notification=lambda: q.queue[-1] if not q.empty() else None,
|
get_current_notification=lambda: q.queue[-1] if not q.empty() else None,
|
||||||
|
_current_notification=None,
|
||||||
|
_notification_expiry=0.0,
|
||||||
is_dirty=False,
|
is_dirty=False,
|
||||||
last_update=time.time(),
|
last_update=time.time(),
|
||||||
last_activity=time.time(),
|
last_activity=time.time(),
|
||||||
@@ -45,11 +47,7 @@ def test_display_menu_prints_notifications(monkeypatch, capsys):
|
|||||||
"clear_header_with_notification",
|
"clear_header_with_notification",
|
||||||
lambda pm, *a, **k: (
|
lambda pm, *a, **k: (
|
||||||
print("HEADER"),
|
print("HEADER"),
|
||||||
print(
|
print(main.get_notification_text(pm)),
|
||||||
pm.get_current_notification().message
|
|
||||||
if pm.get_current_notification()
|
|
||||||
else ""
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
monkeypatch.setattr(main, "timed_input", lambda *a, **k: "")
|
monkeypatch.setattr(main, "timed_input", lambda *a, **k: "")
|
||||||
|
Reference in New Issue
Block a user