This is an automated email from the ASF dual-hosted git repository.

turbaszek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/master by this push:
     new 3d3c042  Added test for bigquery sensor (#8986)
3d3c042 is described below

commit 3d3c0425b1e69bd60b9d0f01188eb1e906d5675c
Author: Joppe Vos <44348300+joppe...@users.noreply.github.com>
AuthorDate: Fri May 29 17:03:38 2020 +0200

    Added test for bigquery sensor (#8986)
    
    * added small test for bigquery sensor
    
    * removed file from missing_test_files
---
 .../google/cloud/sensors/test_bigquery.py          | 53 ++++++++++++++++++++++
 tests/test_project_structure.py                    |  1 -
 2 files changed, 53 insertions(+), 1 deletion(-)

diff --git a/tests/providers/google/cloud/sensors/test_bigquery.py 
b/tests/providers/google/cloud/sensors/test_bigquery.py
new file mode 100644
index 0000000..0c9735e
--- /dev/null
+++ b/tests/providers/google/cloud/sensors/test_bigquery.py
@@ -0,0 +1,53 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from unittest import TestCase, mock
+
+from airflow.providers.google.cloud.sensors.bigquery import 
BigQueryTableExistenceSensor
+
+TEST_PROJECT_ID = "test_project"
+TEST_DATASET_ID = 'test_dataset'
+TEST_TABLE_ID = 'test_table'
+TEST_DELEGATE_TO = "test_delegate_to"
+TEST_GCP_CONN_ID = 'test_gcp_conn_id'
+
+
+class TestBigqueryTableExistenceSensor(TestCase):
+    @mock.patch("airflow.providers.google.cloud.sensors.bigquery.BigQueryHook")
+    def test_passing_arguments_to_hook(self, mock_hook):
+        task = BigQueryTableExistenceSensor(
+            task_id='task-id',
+            project_id=TEST_PROJECT_ID,
+            dataset_id=TEST_DATASET_ID,
+            table_id=TEST_TABLE_ID,
+            bigquery_conn_id=TEST_GCP_CONN_ID,
+            delegate_to=TEST_DELEGATE_TO
+        )
+        mock_hook.return_value.table_exists.return_value = True
+        results = task.poke(mock.MagicMock())
+
+        self.assertEqual(True, results)
+
+        mock_hook.assert_called_once_with(
+            bigquery_conn_id=TEST_GCP_CONN_ID,
+            delegate_to=TEST_DELEGATE_TO
+        )
+        mock_hook.return_value.table_exists.assert_called_once_with(
+            TEST_PROJECT_ID,
+            TEST_DATASET_ID,
+            TEST_TABLE_ID
+        )
diff --git a/tests/test_project_structure.py b/tests/test_project_structure.py
index e8de166..5c34338 100644
--- a/tests/test_project_structure.py
+++ b/tests/test_project_structure.py
@@ -36,7 +36,6 @@ MISSING_TEST_FILES = {
     'tests/providers/cncf/kubernetes/operators/test_kubernetes_pod.py',
     'tests/providers/google/cloud/operators/test_datastore.py',
     'tests/providers/google/cloud/operators/test_sql_to_gcs.py',
-    'tests/providers/google/cloud/sensors/test_bigquery.py',
     'tests/providers/google/cloud/utils/test_field_sanitizer.py',
     'tests/providers/google/cloud/utils/test_field_validator.py',
     'tests/providers/google/cloud/utils/test_mlengine_operator_utils.py',

Reply via email to