Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions tests/test_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,10 @@ async def send(self, msg):
sent.append(msg)
monitor._stop_event.set()

async def immediate_timeout(_aw, timeout=None): # noqa: ARG001
async def immediate_timeout():
raise TimeoutError

monkeypatch.setattr(
"polymarket_copier.core.monitor.asyncio.wait_for",
immediate_timeout,
)
monkeypatch.setattr(monitor._subscription_update_requested, "wait", immediate_timeout)

await monitor._ws_heartbeat(FakeWS())
assert sent == ["PING"]
Expand All @@ -262,7 +259,7 @@ class FakeWS:
async def send(self, msg):
sent.append(msg)

async def first_wake_then_stop(_aw, timeout=None): # noqa: ARG001
async def first_wake_then_stop():
nonlocal wait_calls
wait_calls += 1
if wait_calls == 1:
Expand All @@ -273,10 +270,7 @@ async def first_wake_then_stop(_aw, timeout=None): # noqa: ARG001
async def no_sub(_ws):
return None

monkeypatch.setattr(
"polymarket_copier.core.monitor.asyncio.wait_for",
first_wake_then_stop,
)
monkeypatch.setattr(monitor._subscription_update_requested, "wait", first_wake_then_stop)
monkeypatch.setattr(monitor, "_maybe_update_subscription", no_sub)

await monitor._ws_heartbeat(FakeWS())
Expand Down Expand Up @@ -656,7 +650,7 @@ class FakeWS:
async def send(self, msg):
sent.append(msg)

async def wake_sub_then_timeout_ping(_aw, timeout=None): # noqa: ARG001
async def wake_sub_then_timeout_ping():
"""First wait: subscription Event is set; second: interval elapsed → PING."""
nonlocal wait_calls
wait_calls += 1
Expand All @@ -665,10 +659,7 @@ async def wake_sub_then_timeout_ping(_aw, timeout=None): # noqa: ARG001
monitor._stop_event.set()
raise TimeoutError

monkeypatch.setattr(
"polymarket_copier.core.monitor.asyncio.wait_for",
wake_sub_then_timeout_ping,
)
monkeypatch.setattr(monitor._subscription_update_requested, "wait", wake_sub_then_timeout_ping)

await monitor._ws_heartbeat(FakeWS())

Expand Down
Loading