mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-04-20 22:13:49 +00:00
Fix test_r03 mock to resolve events immediately
The test_r03_placeholder_registered_before_send test used a bare MagicMock dispatcher whose subscribe never resolved event futures, causing send() to block for DEFAULT_TIMEOUT (15s). Add a resolving subscribe mock matching the pattern from the fixture fix on fix/test-timeout-waste.
This commit is contained in:
parent
1a017709c5
commit
4c1e5f4fe2
1 changed files with 10 additions and 0 deletions
|
|
@ -177,6 +177,16 @@ async def test_r03_placeholder_registered_before_send():
|
|||
return_value=Event(EventType.MSG_SENT, {"expected_ack": b"\x01\x02\x03\x04"})
|
||||
)
|
||||
|
||||
# Resolve subscribed events immediately so send() doesn't block
|
||||
def resolving_subscribe(event_type, cb, attribute_filters=None):
|
||||
sub = MagicMock()
|
||||
sub.unsubscribe = MagicMock()
|
||||
asyncio.get_event_loop().call_soon(
|
||||
cb, Event(event_type, {})
|
||||
)
|
||||
return sub
|
||||
handler.dispatcher.subscribe = MagicMock(side_effect=resolving_subscribe)
|
||||
|
||||
# Call send_binary_req
|
||||
dst = "aa" * 32 # 32-byte hex pubkey
|
||||
await handler.send_binary_req(dst, BinaryReqType.MMA)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue