mik-laj commented on a change in pull request #6777: [AIRFLOW-6223] BigQuery -
improve hook tests [depends on AIRFLOW-6220]
URL: https://github.com/apache/airflow/pull/6777#discussion_r356633892
##########
File path: tests/gcp/hooks/test_bigquery.py
##########
@@ -416,14 +440,22 @@ def test_insert_all_fail(self):
}
]
}
- cursor = hook.BigQueryBaseCursor(mock_service, 'project_id')
- with self.assertRaises(Exception):
+ mock_get_creds_and_proj_id.return_value = ("CREDENTIALS", project_id)
+ bq_hook = hook.BigQueryHook()
+ cursor = bq_hook.get_cursor()
+ with self.assertRaisesRegex(
+ Exception,
+ r"BigQuery job failed\. Error was: 1 insert error\(s\) occurred: "
+ r"bq-project:bq_dataset\.bq_table\. Details: \[{'index': 1,
'errors': \[\]}\]"
+ ):
cursor.insert_all(project_id, dataset_id, table_id,
rows, fail_on_error=True)
class TestTableOperations(unittest.TestCase):
- def test_create_view_fails_on_exception(self):
+
@mock.patch('airflow.gcp.hooks.base.CloudBaseHook._get_credentials_and_project_id')
Review comment:
```suggestion
@mock.patch('airflow.gcp.hooks.base.CloudBaseHook._get_credentials_and_project_id',
return_value=("CREDENTIALS", "PROJECT_ID",))
```
For consistency
----------------------------------------------------------------
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]
With regards,
Apache Git Services