예제 #1
0
 def test_list_queues(self, mock_hook):
     mock_hook.return_value.list_queues.return_value = mock.MagicMock()
     operator = CloudTasksQueuesListOperator(location=LOCATION, task_id="id")
     operator.execute(context=None)
     mock_hook.assert_called_once_with(gcp_conn_id=GCP_CONN_ID)
     mock_hook.return_value.list_queues.assert_called_once_with(
         location=LOCATION,
         project_id=None,
         results_filter=None,
         page_size=None,
         retry=None,
         timeout=None,
         metadata=None,
     )
예제 #2
0
    def test_list_queues(self, mock_hook):
        mock_hook.return_value.list_queues.return_value = [TEST_QUEUE]
        operator = CloudTasksQueuesListOperator(location=LOCATION,
                                                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.list_queues.assert_called_once_with(
            location=LOCATION,
            project_id=None,
            results_filter=None,
            page_size=None,
            retry=None,
            timeout=None,
            metadata=None,
        )
예제 #3
0
    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,
        delete_queue,
    )

    # Tasks operations
    create_task = CloudTasksTaskCreateOperator(
        location=LOCATION,