def test_sensor(self): sensor = operators.HttpSensor( task_id='http_sensor_check', conn_id='http_default', endpoint='/search', params={"client": "ubuntu", "q": "airflow"}, headers={}, response_check=lambda response: ("airbnb/airflow" in response.text), poke_interval=5, timeout=15, dag=self.dag) sensor.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, force=True)
def test_sensor_timeout(self): sensor = operators.HttpSensor( task_id='http_sensor_check', conn_id='http_default', endpoint='/search', params={"client": "ubuntu", "q": "airflow"}, headers={}, response_check=lambda response: ("dingdong" in response.text), poke_interval=2, timeout=5, dag=self.dag) with self.assertRaises(utils.AirflowSensorTimeout): sensor.run( start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, force=True)