msumit commented on a change in pull request #15795:
URL: https://github.com/apache/airflow/pull/15795#discussion_r637737138



##########
File path: airflow/models/connection.py
##########
@@ -348,6 +348,25 @@ def debug_info(self):
             self.extra_dejson,
         )
 
+    def test_connection(self):
+        """Calls out get_hook method and executes test_connection method on 
that."""
+        status, message = False, ''
+        try:
+            hook = self.get_hook()
+            if hook and getattr(hook, 'test_connection', False):
+                status, message = hook.test_connection()
+            else:
+                message = (
+                    f"Hook {hook.__class__.__name__} doesn't implement or 
inherit test_connection method"

Review comment:
       Ok, I was wrong, the `get_hook` does not return a `None`. It raises an 
exception if the hook is not found. 




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


Reply via email to