potiuk commented on a change in pull request #8868:
URL: https://github.com/apache/airflow/pull/8868#discussion_r432937816
##########
File path: tests/providers/google/cloud/operators/test_bigquery.py
##########
@@ -788,3 +789,65 @@ def test_execute(self, mock_hook):
project_id=TEST_GCP_PROJECT_ID,
table_resource=TEST_TABLE_RESOURCES
)
+
+
+class TestBigQueryInsertJobOperator:
+
@mock.patch('airflow.providers.google.cloud.operators.bigquery.BigQueryHook')
+ def test_execute(self, mock_hook):
+ job_id = "123456"
+ configuration = {
+ "query": {
+ "query": "SELECT * FROM any",
+ "useLegacySql": False,
+ }
+ }
+ mock_hook.return_value.insert_job.return_value =
MagicMock(job_id=job_id)
+
+ op = BigQueryInsertJobOperator(
+ task_id="insert_query_job",
+ configuration=configuration,
+ location=TEST_DATASET_LOCATION,
+ job_id=job_id,
+ project_id=TEST_GCP_PROJECT_ID
+ )
+ result = op.execute({})
+
+ mock_hook.return_value.insert_job.assert_called_once_with(
+ configuration=configuration,
+ location=TEST_DATASET_LOCATION,
+ job_id=job_id,
+ project_id=TEST_GCP_PROJECT_ID,
+ )
+
+ assert result == job_id
+
+
@mock.patch('airflow.providers.google.cloud.operators.bigquery.BigQueryHook')
Review comment:
It's not super needed - nice to have - but I thought it might be useful
to add.
----------------------------------------------------------------
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]