Commit e216d4a 1 parent de873fc commit e216d4a Copy full SHA for e216d4a
File tree 2 files changed +7
-7
lines changed
2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -17,10 +17,10 @@ async def ack(self) -> None:
17
17
await self .raw_message .ack ()
18
18
await super ().ack ()
19
19
20
- def ack_sync (self ) -> None :
20
+ async def ack_sync (self ) -> None :
21
21
if not self .raw_message ._ackd :
22
- self .raw_message .ack_sync ()
23
- super ().ack ()
22
+ await self .raw_message .ack_sync ()
23
+ await super ().ack ()
24
24
25
25
async def nack (
26
26
self ,
Original file line number Diff line number Diff line change 1
1
import asyncio
2
- from unittest .mock import MagicMock , Mock , patch
2
+ from unittest .mock import Mock , patch
3
3
4
4
import pytest
5
5
from nats .aio .msg import Msg
@@ -224,21 +224,21 @@ async def test_consume_ack_sync_manual(
224
224
225
225
@consume_broker .subscriber (queue , stream = stream )
226
226
async def handler (msg : NatsMessage ):
227
- msg .ack_sync ()
227
+ await msg .ack_sync ()
228
228
event .set ()
229
229
230
230
async with self .patch_broker (consume_broker ) as br :
231
231
await br .start ()
232
232
233
- with patch .object (Msg , "ack_sync" , new_callable = MagicMock ) as m :
233
+ with patch .object (Msg , "ack_sync" , spy_decorator ( Msg . ack_sync ) ) as m :
234
234
await asyncio .wait (
235
235
(
236
236
asyncio .create_task (br .publish ("hello" , queue )),
237
237
asyncio .create_task (event .wait ()),
238
238
),
239
239
timeout = 3 ,
240
240
)
241
- m .assert_called_once ()
241
+ m .mock . assert_called_once ()
242
242
243
243
assert event .is_set ()
244
244
You can’t perform that action at this time.
0 commit comments