ashb commented on a change in pull request #2450: [Airflow-1413] Fix FTPSensor 
failing on error message with unexpected text.
URL: https://github.com/apache/incubator-airflow/pull/2450#discussion_r241337462
 
 

 ##########
 File path: tests/contrib/sensors/test_ftp_sensor.py
 ##########
 @@ -66,6 +71,27 @@ def test_poke_fails_due_error(self):
 
         self.assertTrue("530" in str(context.exception))
 
+    def test_poke_fail_on_transient_error(self):
+        op = FTPSensor(path="foobar.json", ftp_conn_id="bob_ftp",
+                       task_id="test_task")
+
+        self.hook_mock.get_mod_time.side_effect = \
+            error_perm("434: Host unavailable")
+
+        with self.assertRaises(error_perm) as context:
+            op.execute(None)
+
+        self.assertTrue("434" in str(context.exception))
+
+    def test_poke_ignore_transient_error(self):
+        op = FTPSensor(path="foobar.json", ftp_conn_id="bob_ftp",
+                       task_id="test_task", fail_on_transient_errors=False)
+
+        self.hook_mock.get_mod_time.side_effect = \
+            [error_perm("434: Host unavailable"), None]
+
+        self.assertFalse(op.poke(None))
+        self.assertTrue(op.poke(None))
 
 if __name__ == '__main__':
 
 Review comment:
   Tests are now failing the style check here with:
   
   > ./tests/contrib/sensors/test_ftp_sensor.py:96:1: E305 expected 2 blank 
lines after class or function definition, found 1
   
   ```suggestion
   
   if __name__ == '__main__':
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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