Exemplo n.º 1
0
 def test_files_deleted_between_pokes_allow_delete(self):
     self.sensor = gcs_sensor.GoogleCloudStorageUploadSessionCompleteSensor(
         task_id='sensor',
         bucket='test-bucket',
         prefix='test-prefix/path',
         inactivity_period=12,
         poke_interval=10,
         min_objects=1,
         allow_delete=True,
         previous_num_objects=0,
         dag=self.dag)
     self.sensor.is_bucket_updated(2)
     self.assertEqual(self.sensor.inactivity_seconds, 0)
     self.sensor.is_bucket_updated(1)
     self.assertEqual(self.sensor.previous_num_objects, 1)
     self.assertEqual(self.sensor.inactivity_seconds, 0)
     self.sensor.is_bucket_updated(2)
     self.assertEqual(self.sensor.inactivity_seconds, 0)
     self.sensor.is_bucket_updated(2)
     self.assertEqual(self.sensor.inactivity_seconds, 10)
     self.assertTrue(self.sensor.is_bucket_updated(2))
Exemplo n.º 2
0
    def setUp(self):
        args = {
            'owner': 'airflow',
            'start_date': DEFAULT_DATE,
            'provide_context': True
        }
        dag = DAG(TEST_DAG_ID + 'test_schedule_dag_once', default_args=args)
        dag.schedule_interval = '@once'
        self.dag = dag

        self.sensor = gcs_sensor.GoogleCloudStorageUploadSessionCompleteSensor(
            task_id='sensor',
            bucket='test-bucket',
            prefix='test-prefix/path',
            inactivity_period=12,
            poke_interval=10,
            min_objects=1,
            allow_delete=False,
            previous_num_objects=0,
            dag=self.dag)
        self.last_mocked_date = datetime(2019, 4, 24, 0, 0, 0)