def test_get_task(self, mock_hook): mock_hook.return_value.get_task.return_value = TEST_TASK operator = CloudTasksTaskGetOperator(location=LOCATION, queue_name=QUEUE_ID, task_name=TASK_NAME, task_id="id") result = operator.execute(context=None) assert { 'app_engine_http_request': { 'body': '', 'headers': {}, 'http_method': 0, 'relative_uri': '' }, 'dispatch_count': 0, 'name': '', 'response_count': 0, 'view': 0, } == result mock_hook.assert_called_once_with( gcp_conn_id=GCP_CONN_ID, impersonation_chain=None, ) mock_hook.return_value.get_task.assert_called_once_with( location=LOCATION, queue_name=QUEUE_ID, task_name=TASK_NAME, project_id=None, response_view=None, retry=None, timeout=None, metadata=None, )
def test_get_task(self, mock_hook): mock_hook.return_value.get_task.return_value = mock.MagicMock() operator = CloudTasksTaskGetOperator( location=LOCATION, queue_name=QUEUE_ID, task_name=TASK_NAME, task_id="id" ) operator.execute(context=None) mock_hook.assert_called_once_with(gcp_conn_id=GCP_CONN_ID) mock_hook.return_value.get_task.assert_called_once_with( location=LOCATION, queue_name=QUEUE_ID, task_name=TASK_NAME, project_id=None, response_view=None, retry=None, timeout=None, metadata=None, )
def test_get_task(self, mock_hook): mock_hook.return_value.get_task.return_value = TEST_TASK operator = CloudTasksTaskGetOperator(location=LOCATION, queue_name=QUEUE_ID, task_name=TASK_NAME, task_id="id") result = operator.execute(context=None) self.assertEqual({'appEngineHttpRequest': {}}, result) mock_hook.assert_called_once_with( gcp_conn_id=GCP_CONN_ID, impersonation_chain=None, ) mock_hook.return_value.get_task.assert_called_once_with( location=LOCATION, queue_name=QUEUE_ID, task_name=TASK_NAME, project_id=None, response_view=None, retry=None, timeout=None, metadata=None, )
) # Tasks operations create_task = CloudTasksTaskCreateOperator( location=LOCATION, queue_name=QUEUE_ID, task=TASK, task_name=TASK_NAME, retry=Retry(maximum=10.0), timeout=5, task_id="create_task_to_run", ) tasks_get = CloudTasksTaskGetOperator( location=LOCATION, queue_name=QUEUE_ID, task_name=TASK_NAME, task_id="tasks_get", ) run_task = CloudTasksTaskRunOperator( location=LOCATION, queue_name=QUEUE_ID, task_name=TASK_NAME, task_id="run_task", ) list_tasks = CloudTasksTasksListOperator(location=LOCATION, queue_name=QUEUE_ID, task_id="list_tasks") delete_task = CloudTasksTaskDeleteOperator(location=LOCATION,