mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-09 15:58:48 +00:00
Add test for relay reload logging
This commit is contained in:
29
src/tests/test_api_reload_relays.py
Normal file
29
src/tests/test_api_reload_relays.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import logging
|
||||
from types import SimpleNamespace
|
||||
|
||||
from seedpass import api
|
||||
|
||||
|
||||
def test_reload_relays_logs_errors(caplog):
|
||||
def close():
|
||||
raise RuntimeError("close fail")
|
||||
|
||||
def init():
|
||||
raise OSError("init fail")
|
||||
|
||||
pm = SimpleNamespace(
|
||||
nostr_client=SimpleNamespace(
|
||||
close_client_pool=close,
|
||||
initialize_client_pool=init,
|
||||
relays=[],
|
||||
)
|
||||
)
|
||||
request = SimpleNamespace(app=SimpleNamespace(state=SimpleNamespace(pm=pm)))
|
||||
|
||||
with caplog.at_level(logging.WARNING):
|
||||
api._reload_relays(request, ["ws://relay"])
|
||||
|
||||
assert "Failed to close NostrClient pool" in caplog.text
|
||||
assert "close fail" in caplog.text
|
||||
assert "Failed to initialize NostrClient with relays" in caplog.text
|
||||
assert "init fail" in caplog.text
|
Reference in New Issue
Block a user