def test_update_queue(self, mock_hook):
     mock_hook.return_value.update_queue.return_value = {}
     operator = CloudTasksQueueUpdateOperator(
         task_queue=Queue(name=FULL_QUEUE_PATH), task_id="id")
     operator.execute(context=None)
     mock_hook.assert_called_once_with(gcp_conn_id=GCP_CONN_ID)
     mock_hook.return_value.update_queue.assert_called_once_with(
         task_queue=Queue(name=FULL_QUEUE_PATH),
         project_id=None,
         location=None,
         queue_name=None,
         update_mask=None,
         retry=None,
         timeout=None,
         metadata=None,
     )
Exemple #2
0
    def test_update_queue(self, mock_hook):
        mock_hook.return_value.update_queue.return_value = TEST_QUEUE
        operator = CloudTasksQueueUpdateOperator(
            task_queue=Queue(name=FULL_QUEUE_PATH), task_id="id")

        result = operator.execute(context=None)

        self.assertEqual({'name': FULL_QUEUE_PATH, 'state': 0}, result)
        mock_hook.assert_called_once_with(
            gcp_conn_id=GCP_CONN_ID,
            impersonation_chain=None,
        )
        mock_hook.return_value.update_queue.assert_called_once_with(
            task_queue=Queue(name=FULL_QUEUE_PATH),
            project_id=None,
            location=None,
            queue_name=None,
            update_mask=None,
            retry=None,
            timeout=None,
            metadata=None,
        )
Exemple #3
0
    get_queue = CloudTasksQueueGetOperator(
        location=LOCATION,
        queue_name=QUEUE_ID,
        task_id="get_queue",
    )

    get_queue_result = BashOperator(
        task_id="get_queue_result",
        bash_command="echo \"{{ task_instance.xcom_pull('get_queue') }}\"",
    )
    get_queue >> get_queue_result

    update_queue = CloudTasksQueueUpdateOperator(
        task_queue=Queue(stackdriver_logging_config=dict(sampling_ratio=1)),
        location=LOCATION,
        queue_name=QUEUE_ID,
        update_mask={"paths": ["stackdriver_logging_config.sampling_ratio"]},
        task_id="update_queue",
    )

    list_queue = CloudTasksQueuesListOperator(location=LOCATION,
                                              task_id="list_queue")

    chain(
        create_queue,
        update_queue,
        pause_queue,
        resume_queue,
        purge_queue,
        get_queue,
        list_queue,