def test_delete_queue(self, mock_hook):
     mock_hook.return_value.delete_queue.return_value = {}
     operator = CloudTasksQueueDeleteOperator(location=LOCATION,
                                              queue_name=QUEUE_ID,
                                              task_id="id")
     operator.execute(context=None)
     mock_hook.assert_called_once_with(gcp_conn_id=GCP_CONN_ID)
     mock_hook.return_value.delete_queue.assert_called_once_with(
         location=LOCATION,
         queue_name=QUEUE_ID,
         project_id=None,
         retry=None,
         timeout=None,
         metadata=None,
     )
예제 #2
0
        tags=['example'],
) as dag:

    # Queue operations
    create_queue = CloudTasksQueueCreateOperator(
        location=LOCATION,
        task_queue=Queue(stackdriver_logging_config=dict(sampling_ratio=0.5)),
        queue_name=QUEUE_ID,
        retry=Retry(maximum=10.0),
        timeout=5,
        task_id="create_queue",
    )

    delete_queue = CloudTasksQueueDeleteOperator(
        location=LOCATION,
        queue_name=QUEUE_ID,
        task_id="delete_queue",
    )

    resume_queue = CloudTasksQueueResumeOperator(
        location=LOCATION,
        queue_name=QUEUE_ID,
        task_id="resume_queue",
    )

    pause_queue = CloudTasksQueuePauseOperator(
        location=LOCATION,
        queue_name=QUEUE_ID,
        task_id="pause_queue",
    )