def test_poke(self, mock_hook): mock_instance = mock_hook.return_value sensor = WasbBlobSensor(task_id='wasb_sensor', dag=self.dag, check_options={'timeout': 2}, **self._config) sensor.poke(None) mock_instance.check_for_blob.assert_called_once_with('container', 'blob', timeout=2)
def test_poke(self, mock_hook): mock_instance = mock_hook.return_value sensor = WasbBlobSensor( task_id='wasb_sensor', dag=self.dag, check_options={'timeout': 2}, **self._config ) sensor.poke(None) mock_instance.check_for_blob.assert_called_once_with( 'container', 'blob', timeout=2 )
def test_init(self): sensor = WasbBlobSensor(task_id='wasb_sensor', dag=self.dag, **self._config) self.assertEqual(sensor.container_name, self._config['container_name']) self.assertEqual(sensor.blob_name, self._config['blob_name']) self.assertEqual(sensor.wasb_conn_id, self._config['wasb_conn_id']) self.assertEqual(sensor.check_options, {}) self.assertEqual(sensor.timeout, self._config['timeout']) sensor = WasbBlobSensor(task_id='wasb_sensor', dag=self.dag, check_options={'timeout': 2}, **self._config) self.assertEqual(sensor.check_options, {'timeout': 2})
import airflow.utils.dates from airflow.models import DAG from airflow.contrib.sensors.wasb_sensor import WasbBlobSensor dag = DAG(dag_id="keyvault_connection", start_date=airflow.utils.dates.days_ago(3), schedule_interval="@once") data_arrival_sensor = WasbBlobSensor(task_id="data_arrival_sensor", container_name="landing", blob_name="raw_data.csv", wasb_conn_id="foo", poke_interval=60, timeout=60 * 60 * 24, dag=dag)