99from taskiq_aio_pika .broker import AioPikaBroker
1010
1111
12- async def get_first_task (broker : AioPikaBroker ) -> BrokerMessage : # type: ignore
12+ async def get_first_task (broker : AioPikaBroker ) -> bytes : # type: ignore
1313 """
1414 Get first message from the queue.
1515
@@ -36,7 +36,7 @@ async def test_kick_success(broker: AioPikaBroker) -> None:
3636 sent = BrokerMessage (
3737 task_id = task_id ,
3838 task_name = task_name ,
39- message = "my_msg" ,
39+ message = b "my_msg" ,
4040 labels = {
4141 "label1" : "val1" ,
4242 },
@@ -46,7 +46,7 @@ async def test_kick_success(broker: AioPikaBroker) -> None:
4646
4747 message = await asyncio .wait_for (get_first_task (broker ), timeout = 0.4 )
4848
49- assert message == sent
49+ assert message == sent . message
5050
5151
5252@pytest .mark .anyio
@@ -111,10 +111,7 @@ async def test_listen(
111111
112112 message = await asyncio .wait_for (get_first_task (broker ), timeout = 0.4 )
113113
114- assert message .message == "test_message"
115- assert message .labels == {"label1" : "label_val" }
116- assert message .task_id == "test_id"
117- assert message .task_name == "task_name"
114+ assert message == b"test_message"
118115
119116
120117@pytest .mark .anyio
@@ -124,7 +121,7 @@ async def test_wrong_format(
124121 test_channel : Channel ,
125122) -> None :
126123 """
127- Tests that messages with wrong format are ignored .
124+ Tests that messages with wrong format are still received .
128125
129126 :param broker: aio-pika broker.
130127 :param queue_name: test queue name.
@@ -136,8 +133,9 @@ async def test_wrong_format(
136133 routing_key = queue_name ,
137134 )
138135
139- with pytest .raises (asyncio .TimeoutError ):
140- await asyncio .wait_for (get_first_task (broker ), 0.4 )
136+ msg_bytes = await asyncio .wait_for (get_first_task (broker ), 0.4 )
137+
138+ assert msg_bytes == b"wrong"
141139
142140 with pytest .raises (QueueEmpty ):
143141 await queue .get ()
@@ -168,7 +166,7 @@ async def test_delayed_message(
168166 broker_msg = BrokerMessage (
169167 task_id = "1" ,
170168 task_name = "name" ,
171- message = "message" ,
169+ message = b "message" ,
172170 labels = {"delay" : "2" },
173171 )
174172 await broker .kick (broker_msg )
0 commit comments