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:
Matthew Wolter 2026-04-12 07:00:10 -07:00
parent 4c1e5f4fe2
commit 74e349be97

View file

@ -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)