feluelle commented on a change in pull request #5101: [AIRFLOW-4319] Add tests 
for Bigquery related Operators
URL: https://github.com/apache/airflow/pull/5101#discussion_r275438792
 
 

 ##########
 File path: tests/contrib/operators/test_bigquery_operator.py
 ##########
 @@ -250,3 +255,125 @@ def test_bigquery_operator_defaults(self, mock_hook):
         ti = TaskInstance(task=operator, execution_date=DEFAULT_DATE)
         ti.render_templates()
         self.assertTrue(isinstance(ti.task.sql, six.string_types))
+
+
+class BigQueryGetDataOperatorTest(unittest.TestCase):
+
+    @mock.patch('airflow.contrib.operators.bigquery_get_data.BigQueryHook')
+    def test_execute(self, mock_hook):
+
+        max_results = '100'
+        selected_fields = 'DATE'
+        operator = BigQueryGetDataOperator(task_id=TASK_ID,
+                                           dataset_id=TEST_DATASET,
+                                           table_id=TEST_TABLE_ID,
+                                           max_results=max_results,
+                                           selected_fields=selected_fields,
+                                           )
+        operator.execute(None)
+        mock_hook.return_value \
+            .get_conn() \
 
 Review comment:
   Note that there is a difference between `()` and `return_value`. 
   With `()` you are actually calling the mock. With `return_value` you don't.
   
   However you won't notice if you don't test for the number of mock calls of 
this particular mock object. For example `.get_conn`.
   
   I recommend to use `return_value` to not extra call the mock object.

----------------------------------------------------------------
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

Reply via email to