dstandish commented on a change in pull request #21385:
URL: https://github.com/apache/airflow/pull/21385#discussion_r800825768



##########
File path: tests/providers/google/cloud/hooks/test_bigquery.py
##########
@@ -943,6 +943,35 @@ def test_dbapi_get_sqlalchemy_engine(self):
         ):
             self.hook.get_sqlalchemy_engine()
 
+    @mock.patch("airflow.providers.google.cloud.hooks.bigquery.QueryJob")
+    
@mock.patch("airflow.providers.google.cloud.hooks.bigquery.BigQueryHook.get_client")
+    def test_insert_job_with_async(self, mock_client, mock_query_job):
+        job_conf = {
+            "query": {
+                "query": "SELECT * FROM test",
+                "useLegacySql": "False",
+            }
+        }
+        mock_query_job._JOB_TYPE = "query"
+
+        self.hook.insert_job(
+            configuration=job_conf, job_id=JOB_ID, project_id=PROJECT_ID, 
location=LOCATION, is_async=True
+        )
+
+        mock_client.assert_called_once_with(
+            project_id=PROJECT_ID,
+            location=LOCATION,
+        )
+
+        mock_query_job.from_api_repr.assert_called_once_with(
+            {
+                'configuration': job_conf,
+                'jobReference': {'jobId': JOB_ID, 'projectId': PROJECT_ID, 
'location': LOCATION},
+            },
+            mock_client.return_value,
+        )
+        mock_query_job.from_api_repr.return_value._begin.assert_called_once()

Review comment:
       what you think of parameterizing this on `is_async`
   
   when true, _begin called, and result not called
   when false, the reverse




-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to