Exemplo n.º 1
0
 def it_should_send_multiple_body_frames(self):
     expected_body1 = frames.ContentBodyFrame(self.channel.id, self.body1)
     expected_body2 = frames.ContentBodyFrame(self.channel.id, self.body2)
     expected_body3 = frames.ContentBodyFrame(self.channel.id, self.body3)
     self.server.should_have_received_frames([
         expected_body1,
         expected_body2,
         expected_body3
     ], any_order=False)
Exemplo n.º 2
0
    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()
Exemplo n.º 3
0
    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()
Exemplo n.º 4
0
    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()
Exemplo n.º 5
0
 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)
Exemplo n.º 6
0
    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()