TobKed commented on a change in pull request #6355: [AIRFLOW-5685] Loading AVRO
file from GCS to BQ throwing ValueError
URL: https://github.com/apache/airflow/pull/6355#discussion_r351863443
##########
File path: tests/gcp/hooks/test_bigquery.py
##########
@@ -407,6 +407,62 @@ def test_validate_src_fmt_configs(self):
assert "compatibility_val" in src_fmt_configs, \
"_validate_src_fmt_configs should add backward_compatibility
config"
+ def test_run_load_with_avro_as_src_fmt(self):
+ with mock.patch.object(hook.BigQueryBaseCursor,
'run_with_configuration'):
+ bq_hook = hook.BigQueryBaseCursor(mock.Mock(), 12345)
+
+ try:
+ bq_hook.run_load(
+ destination_project_dataset_table='my_dataset.my_table',
+ source_uris=[],
+ source_format='AVRO',
+ autodetect=True
+ )
+ except ValueError:
+ self.fail("run_load() raised ValueError unexpectedly!")
+
+ def test_run_load_with_parquet_as_src_fmt(self):
+ with mock.patch.object(hook.BigQueryBaseCursor,
'run_with_configuration'):
+ bq_hook = hook.BigQueryBaseCursor(mock.Mock(), 12345)
+
+ try:
+ bq_hook.run_load(
+ destination_project_dataset_table='my_dataset.my_table',
+ source_uris=[],
+ source_format='PARQUET',
+ autodetect=True
+ )
+ except ValueError:
+ self.fail("run_load() raised ValueError unexpectedly!")
+
+ def test_run_load_with_json_as_src_fmt(self):
+ with mock.patch.object(hook.BigQueryBaseCursor,
'run_with_configuration'):
+ bq_hook = hook.BigQueryBaseCursor(mock.Mock(), 12345)
+
+ try:
+ bq_hook.run_load(
+ destination_project_dataset_table='my_dataset.my_table',
+ source_uris=[],
+ source_format='NEWLINE_DELIMITED_JSON',
+ autodetect=True
+ )
+ except ValueError:
+ self.fail("run_load() raised ValueError unexpectedly!")
+
+ def test_run_load_with_datastore_backup_as_src_fmt(self):
+ with mock.patch.object(hook.BigQueryBaseCursor,
'run_with_configuration'):
+ bq_hook = hook.BigQueryBaseCursor(mock.Mock(), 12345)
+
+ try:
+ bq_hook.run_load(
+ destination_project_dataset_table='my_dataset.my_table',
+ source_uris=[],
+ source_format='DATASTORE_BACKUP',
+ autodetect=True
+ )
+ except ValueError:
+ self.fail("run_load() raised ValueError unexpectedly!")
+
Review comment:
WDYT @mik-laj @nuclearpinguin ?
----------------------------------------------------------------
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