Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_incoming_message_to_message():
raw_message = IncomingMessage(
message=DeliveredMessage(
delivery=Basic.Deliver(
consumer_tag="ctag",
delivery_tag="dtag",
redelivered=True,
exchange="exc",
routing_key="rkey",
),
header=ContentHeader(),
body=b"",
channel=None,
)
)
message = Message(raw_message=raw_message)
assert message.delivery_info["consumer_tag"], "ctag"
from typing import Union, Callable, Any
import aiormq.types
ReturnCallbackType = Callable[[aiormq.types.DeliveredMessage], Any]
CloseCallbackType = Callable[[Exception], Any]
TimeoutType = Union[int, float]
ExchangeType = Union['Exchange', str]
async def _read_content(self, frame, header: ContentHeader):
body = BytesIO()
content = None
if header.body_size:
content = await self._get_frame() # type: ContentBody
while content and body.tell() < header.body_size:
body.write(content.value)
if body.tell() < header.body_size:
content = await self._get_frame()
# noinspection PyTypeChecker
return DeliveredMessage(
delivery=frame, header=header, body=body.getvalue(), channel=self
)
async def basic_get(
self, queue: str = "", no_ack: bool = False
) -> typing.Optional[DeliveredMessage]:
async with self.getter_lock:
self.getter = self.create_future()
await self.rpc(spec.Basic.Get(queue=queue, no_ack=no_ack))
frame, message = await self.getter
self.getter = None
return message