mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-04-20 22:13:49 +00:00
Fix test_r03 resolving mock to include expected_ack payload
send_binary_req reads result.payload['expected_ack'] from MSG_SENT events. The resolving subscribe must provide that key for MSG_SENT event types to avoid KeyError.
This commit is contained in:
parent
4c1e5f4fe2
commit
74e349be97
1 changed files with 4 additions and 2 deletions
|
|
@ -177,12 +177,14 @@ 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
|
||||
# Resolve subscribed events immediately so send() doesn't block.
|
||||
# Use MSG_SENT with expected_ack because send_binary_req reads that key.
|
||||
def resolving_subscribe(event_type, cb, attribute_filters=None):
|
||||
sub = MagicMock()
|
||||
sub.unsubscribe = MagicMock()
|
||||
payload = {"expected_ack": b"\x01\x02\x03\x04"} if event_type == EventType.MSG_SENT else {}
|
||||
asyncio.get_event_loop().call_soon(
|
||||
cb, Event(event_type, {})
|
||||
cb, Event(event_type, payload)
|
||||
)
|
||||
return sub
|
||||
handler.dispatcher.subscribe = MagicMock(side_effect=resolving_subscribe)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue