airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [airflow] dinigo commented on a change in pull request #17592: Support for passing arguments to SqlSensor underlying hooks
Date Thu, 19 Aug 2021 12:39:25 GMT

dinigo commented on a change in pull request #17592:
URL: https://github.com/apache/airflow/pull/17592#discussion_r692071092



##########
File path: tests/sensors/test_sql_sensor.py
##########
@@ -242,6 +242,22 @@ def test_sql_sensor_postgres_poke_invalid_success(self, mock_hook):
             op.poke(None)
         assert "self.success is present, but not callable -> [1]" == str(ctx.value)
 
+    @mock.patch('airflow.sensors.sql.BaseHook')
+    def test_sql_sensor_bigquery_hook_kwargs(self, mock_hook):
+        op = SqlSensor(
+            task_id='sql_sensor_check',
+            conn_id='postgres_default',
+            sql="SELECT 1",
+            hook_kwargs={
+                'use_legacy_sql': False,
+                'location': 'test_location',
+            },
+        )
+
+        mock_hook.get_connection('google_cloud_default').conn_type = "google_cloud_platform"
+        assert op._get_hook().use_legacy_sql
+        assert op._get_hook().location == 'test_location'

Review comment:
       You mean mocking also the BaseHook and checking that call arguments match the `** hook_kwargs`?
you are right




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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



Mime
View raw message