コード例 #1
0
ファイル: test_amqp.py プロジェクト: kevinconway/PyPerf
    def test_can_place_message_on_queue(self):

        # Roll a UUID to make sure we're getting the right message.
        secret = str(uuid.uuid4())

        # Generate a transport and place a message on the queue.
        trans = AmqpTransport(
            host='localhost',
            username='******',
            password='******',
            queue=self._test_id,
        )

        message = ProfileRequest(0, secret, secret)
        trans.send(message)

        # Use the raw client to fetch to message.
        # Placed in a while loop to prevent false test failures due to
        # occasional race conditions.
        raw_message = None
        while raw_message is None:
            raw_message = self._channel.basic_get(self._test_id)
        # Find the secret.
        self.assertTrue(secret in raw_message.body)
        # ACK the message to avoid breaking other tests.
        self._channel.basic_ack(raw_message.delivery_tag)
コード例 #2
0
ファイル: test_amqp.py プロジェクト: rackerlabs/PyPerf
    def test_can_place_message_on_queue(self):

        # Roll a UUID to make sure we're getting the right message.
        secret = str(uuid.uuid4())

        # Generate a transport and place a message on the queue.
        trans = AmqpTransport(
            host='localhost',
            username='******',
            password='******',
            queue=self._test_id,
        )

        message = ProfileRequest(0, secret, secret)
        trans.send(message)

        # Use the raw client to fetch to message.
        # Placed in a while loop to prevent false test failures due to
        # occasional race conditions.
        raw_message = None
        while raw_message is None:
            raw_message = self._channel.basic_get(self._test_id)
        # Find the secret.
        self.assertTrue(secret in raw_message.body)
        # ACK the message to avoid breaking other tests.
        self._channel.basic_ack(raw_message.delivery_tag)