def test_create_queue(self, mock_hook):
     mock_hook.return_value.create_queue.return_value = {}
     operator = CloudTasksQueueCreateOperator(location=LOCATION,
                                              task_queue=Queue(),
                                              task_id="id")
     operator.execute(context=None)
     mock_hook.assert_called_once_with(gcp_conn_id=GCP_CONN_ID)
     mock_hook.return_value.create_queue.assert_called_once_with(
         location=LOCATION,
         task_queue=Queue(),
         project_id=None,
         queue_name=None,
         retry=None,
         timeout=None,
         metadata=None,
     )
Esempio n. 2
0
    def test_create_queue(self, mock_hook):
        mock_hook.return_value.create_queue.return_value = TEST_QUEUE
        operator = CloudTasksQueueCreateOperator(location=LOCATION,
                                                 task_queue=TEST_QUEUE,
                                                 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.create_queue.assert_called_once_with(
            location=LOCATION,
            task_queue=TEST_QUEUE,
            project_id=None,
            queue_name=None,
            retry=None,
            timeout=None,
            metadata=None,
        )