jaketf commented on a change in pull request #8553:
URL: https://github.com/apache/airflow/pull/8553#discussion_r418996024
##########
File path: tests/providers/google/cloud/hooks/test_dataflow.py
##########
@@ -692,10 +710,84 @@ def test_cancel_job(self, mock_get_conn, jobs_controller):
location=TEST_LOCATION,
name=TEST_JOB_NAME,
poll_sleep=10,
- project_number=TEST_PROJECT
+ project_number=TEST_PROJECT,
+ num_retries=5,
)
jobs_controller.cancel()
+ @mock.patch(DATAFLOW_STRING.format('_DataflowJobsController'))
+
@mock.patch(DATAFLOW_STRING.format('DataflowHook.provide_authorized_gcloud'))
+ @mock.patch(DATAFLOW_STRING.format('DataflowHook.get_conn'))
+ @mock.patch(DATAFLOW_STRING.format('subprocess.run'))
+ def test_start_sql_job_failed_to_run(
+ self, mock_run, mock_get_conn, mock_provide_authorized_gcloud,
mock_controller
+ ):
+ test_job = {'id': "TEST_JOB_ID"}
+ mock_controller.return_value.get_jobs.return_value = [test_job]
+ mock_run.return_value = mock.MagicMock(
+ stdout=f"{TEST_JOB_ID}\n".encode(),
+ stderr=f"{TEST_JOB_ID}\n".encode(),
+ returncode=0
+ )
+ on_new_job_id_callback = mock.MagicMock()
+ result = self.dataflow_hook.start_sql_job(
+ job_name=TEST_SQL_JOB_NAME,
+ query=TEST_SQL_QUERY,
+ options=TEST_SQL_OPTIONS,
+ location=TEST_LOCATION,
+ project_id=TEST_PROJECT,
+ on_new_job_id_callback=on_new_job_id_callback
+ )
+ mock_run.assert_called_once_with(
+ [
+ 'gcloud',
+ 'beta',
Review comment:
beta not necessary
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]