You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/03/05 22:00:13 UTC

[GitHub] [airflow] frankcash commented on a change in pull request #21997: [Feature] Updates FTPHook provider to have test_connection

frankcash commented on a change in pull request #21997:
URL: https://github.com/apache/airflow/pull/21997#discussion_r820152092



##########
File path: tests/providers/ftp/hooks/test_ftp.py
##########
@@ -120,6 +120,19 @@ def test_retrieve_file_with_callback(self):
             ftp_hook.retrieve_file(self.path, _buffer, callback=func)
         self.conn_mock.retrbinary.assert_called_once_with('RETR path', func)
 
+    def test_connection_success(self):
+        with fh.FTPHook() as ftp_hook:
+            status, msg = ftp_hook.test_connection()
+            assert status is True
+            assert msg == 'Connection successfully tested'
+        
+    def test_connection_failure(self):
+        self.conn_mock = mock.MagicMock(name='conn_mock', side_effect=Exception('Test'))
+        fh.FTPHook.get_conn = self.conn_mock
+        with fh.FTPHook() as ftp_hook:
+            status, msg = ftp_hook.test_connection()
+            assert status is False
+            assert msg == 'Test'
 

Review comment:
       `Suggestion cannot be identical to original text. `
   




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