def when_BasicGetOK_arrives_with_content(self): method = spec.BasicGetOK(123, False, 'my.exchange', 'routing.key', 0) self.server.send_method(self.channel.id, method) header = message.get_header_payload(self.expected_message, spec.BasicGet.method_type[0]) self.server.send_frame(frames.ContentHeaderFrame(self.channel.id, header)) body = message.get_frame_payloads(self.expected_message, 100)[0] self.server.send_frame(frames.ContentBodyFrame(self.channel.id, body)) self.tick()
def deliver_msg(self): method = spec.BasicDeliver(self.consumer.tag, 123, False, 'my.exchange', 'routing.key') self.server.send_method(self.channel.id, method) header = message.get_header_payload(self.expected_message, spec.BasicGet.method_type[0]) self.server.send_frame(frames.ContentHeaderFrame(self.channel.id, header)) body = message.get_frame_payloads(self.expected_message, 100)[0] self.server.send_frame(frames.ContentBodyFrame(self.channel.id, body)) self.tick()
def return_msg(self): method = spec.BasicReturn(123, "you messed up", "the.exchange", "the.routing.key") self.server.send_frame(frames.MethodFrame(self.channel.id, method)) header = message.get_header_payload(self.expected_message, spec.BasicGet.method_type[0]) self.server.send_frame(frames.ContentHeaderFrame(self.channel.id, header)) body = message.get_frame_payloads(self.expected_message, 100)[0] self.server.send_frame(frames.ContentBodyFrame(self.channel.id, body)) self.tick()
def when_BasicDeliver_arrives_with_content(self): method = spec.BasicDeliver(self.consumer.tag, 123, False, 'my.exchange', 'routing.key') self.dispatcher.dispatch(frames.MethodFrame(self.channel.id, method)) self.tick() header = message.get_header_payload(self.expected_message, spec.BasicGet.method_type[0]) self.dispatcher.dispatch(frames.ContentHeaderFrame(self.channel.id, header)) self.tick() body = message.get_frame_payloads(self.expected_message, 100)[0] self.dispatcher.dispatch(frames.ContentBodyFrame(self.channel.id, body)) self.tick() self.tick()
def given_I_received_a_message(self): self.delivery_tag = 12487 msg = asynqp.Message('body', timestamp=datetime(2014, 5, 5)) task = asyncio.ensure_future(self.queue.get()) self.tick() method = spec.BasicGetOK(self.delivery_tag, False, 'my.exchange', 'routing.key', 0) self.server.send_method(self.channel.id, method) header = message.get_header_payload(msg, spec.BasicGet.method_type[0]) self.server.send_frame(frames.ContentHeaderFrame(self.channel.id, header)) body = message.get_frame_payloads(msg, 100)[0] self.server.send_frame(frames.ContentBodyFrame(self.channel.id, body)) self.tick() self.msg = task.result()
def given_I_received_a_message(self): self.delivery_tag = 12487 msg = asynqp.Message('body', timestamp=datetime(2014, 5, 5)) task = asyncio.async(self.queue.get()) self.tick() method = spec.BasicGetOK(self.delivery_tag, False, 'my.exchange', 'routing.key', 0) self.server.send_method(self.channel.id, method) header = message.get_header_payload(msg, spec.BasicGet.method_type[0]) self.server.send_frame(frames.ContentHeaderFrame(self.channel.id, header)) body = message.get_frame_payloads(msg, 100)[0] self.server.send_frame(frames.ContentBodyFrame(self.channel.id, body)) self.tick() self.msg = task.result()
def because_the_message_is_longer_than_the_max_size(self): self.frames = message.get_frame_payloads(self.message, 5)
def when_I_get_the_frames(self): self.frames = message.get_frame_payloads(self.message, 100)