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 given_a_frame(self): self.raw = ( b'\x01\x00\x01\x00\x00\x00\x22' # type, channel, size b'\x00\x3C\x00\x47' # 60, 71 b'\x00\x00\x00\x00\x00\x00\x00\x01' # delivery tag b'\x00' # not redelivered b'\x08exchange' b'\x07routing' b'\x00\x00\x00\x00' # no more messages b'\xCE') expected_method = spec.BasicGetOK(1, False, 'exchange', 'routing', 0) self.expected_frame = frames.MethodFrame(1, expected_method)
def it_should_send_a_BasicPublish_method_followed_by_a_header_and_the_body( self): expected_method = spec.BasicPublish(0, self.exchange.name, 'routing.key', True, False) header_payload = message.ContentHeaderPayload(60, 4, [ 'application/json', 'utf-8', {}, 2, 5, self.correlation_id, 'me', 'tomorrow', self.message_id, self.timestamp, 'telegram', 'benjamin', 'asynqptests' ]) expected_header = frames.ContentHeaderFrame(self.channel.id, header_payload) expected_body = frames.ContentBodyFrame(self.channel.id, b'body') self.server.should_have_received_frames([ frames.MethodFrame(self.channel.id, expected_method), expected_header, expected_body ], any_order=False)