airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [airflow] TobKed commented on a change in pull request #6355: [AIRFLOW-5685] Loading AVRO file from GCS to BQ throwing ValueError
Date Mon, 25 Nov 2019 15:41:48 GMT
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_r350258788
 
 

 ##########
 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 about using `parameterized` library to iterate over the tested parameters? It will
eliminate redundancy since the tests are differ only slightly.
   Here is some example:
   https://github.com/apache/airflow/blob/master/tests/gcp/operators/test_cloud_build.py#L66
   (be aware that running single parameterized test may be problematic but running the whole
test class should be fine, also worth to mention is that if parameterized test raise Exception
the traceback is little bit confusing)

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message