XD-DENG commented on a change in pull request #4878: [AIRFLOW-4046] Added
validations for poke_interval & timeout for Airflow Sensor
URL: https://github.com/apache/airflow/pull/4878#discussion_r264008594
##########
File path: tests/sensors/test_base_sensor.py
##########
@@ -464,3 +464,43 @@ def test_reschedule_with_test_mode(self):
self.assertEqual(len(task_reschedules), 0)
if ti.task_id == DUMMY_OP:
self.assertEqual(ti.state, State.NONE)
+
+ def test_sensor_with_invalid_poke_interval(self):
+ negative_poke_interval = -10
+ non_number_poke_interval = "abcd"
+ positive_poke_interval = 10
+ with self.assertRaises(AirflowException):
+ self._make_sensor(
+ return_value=None,
+ poke_interval=negative_poke_interval,
+ timeout=25)
+
+ self._make_sensor(
+ return_value=None,
+ poke_interval=non_number_poke_interval,
+ timeout=25)
Review comment:
Sorry for having missed to point this out: I think you should have another
`with self.assertRaises(AirflowException):` for the 2nd check on
`non_number_poke_interval`.
When you run with `negative_poke_interval`, the `assertRaises` is already
triggered and this chunk will stop. So your check on `non_number_poke_interval`
is not really running.
----------------------------------------------------------------
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]
With regards,
Apache Git Services