Nataneljpwd commented on code in PR #52700:
URL: https://github.com/apache/airflow/pull/52700#discussion_r2291643823


##########
providers/sftp/src/airflow/providers/sftp/sensors/sftp.py:
##########
@@ -135,6 +137,20 @@ def poke(self, context: Context) -> PokeReturnValue | bool:
         else:
             files_found = actual_files_present
 
+        return files_found
+
+    def poke(self, context: Context) -> PokeReturnValue | bool:
+        self.hook = SFTPHook(self.sftp_conn_id, 
use_managed_conn=self.use_managed_conn)
+
+        self.log.info("Poking for %s, with pattern %s", self.path, 
self.file_pattern)
+        files_found = []

Review Comment:
   done



##########
providers/sftp/tests/unit/sftp/sensors/test_sftp.py:
##########
@@ -97,6 +97,14 @@ def test_file_new_enough(self, sftp_hook_mock):
         sftp_hook_mock.return_value.close_conn.assert_not_called()
         assert output
 
+    @patch("airflow.providers.sftp.sensors.sftp.SFTPHook")
+    def test_only_creating_one_connection_with_unmanaged_conn(self, 
sftp_hook_mock):
+        sftp_hook_mock.return_value.isfile.return_value = True
+        sftp_hook_mock.return_value.get_mod_time.return_value = 
"19700101000000"
+        sftp_sensor = SFTPSensor(task_id="test", path="path/to/whatever/test", 
use_managed_conn=False)
+        sftp_sensor.poke({})
+        sftp_hook_mock.return_value.get_managed_conn.assert_called_once_with()

Review Comment:
   done



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to