Beispiel #1
0
    def test_get_task(self):
        """Test getting a task from the upload queue"""
        b = BossBackend(self.example_config_data)
        b.setup(self.api_token)

        # Make sure queue is empty.
        sqs = boto3.resource('sqs')
        queue = sqs.Queue(self.upload_queue_url)
        queue.purge()

        # Put some stuff on the task queue
        self.setup_helper.add_tasks(self.aws_creds["access_key"],
                                    self.aws_creds['secret_key'],
                                    self.upload_queue_url, b)

        # Join and get a task
        b.join(23)
        msg_id, rx_handle, msg_body = b.get_task()

        assert isinstance(msg_id, str)
        assert isinstance(rx_handle, str)
        assert msg_body == self.setup_helper.test_msg[0]

        msg_id, rx_handle, msg_body = b.get_task()
        assert isinstance(msg_id, str)
        assert isinstance(rx_handle, str)
        assert msg_body == self.setup_helper.test_msg[1]
Beispiel #2
0
    def test_delete_task(self):
        b = BossBackend(self.example_config_data)
        b.setup(self.api_token)

        # Make sure queue is empty.
        sqs = boto3.resource('sqs')
        queue = sqs.Queue(self.upload_queue_url)
        queue.purge()

        # Put some stuff on the task queue
        self.setup_helper.add_tasks(self.aws_creds["access_key"],
                                    self.aws_creds['secret_key'],
                                    self.upload_queue_url, b)

        # Join and get a task
        b.join(23)
        msg_id, rx_handle, msg_body = b.get_task()

        assert b.delete_task(msg_id, rx_handle)