Пример #1
0
 def test_weekday_sensor_true(self):
     op = DayOfWeekSensor(task_id='weekday_sensor_check_true',
                          week_day='Thursday',
                          use_task_execution_day=True,
                          dag=self.dag)
     op.run(start_date=WEEKDAY_DATE,
            end_date=WEEKDAY_DATE,
            ignore_ti_state=True)
Пример #2
0
 def test_weekday_sensor_true(self, _, week_day):
     op = DayOfWeekSensor(
         task_id='weekday_sensor_check_true',
         week_day=week_day,
         use_task_execution_day=True,
         dag=self.dag)
     op.run(start_date=WEEKDAY_DATE, end_date=WEEKDAY_DATE, ignore_ti_state=True)
     self.assertEqual(op.week_day, week_day)
Пример #3
0
 def test_weekday_sensor_with_enum_set(self):
     week_day = {WeekDay.THURSDAY}
     op = DayOfWeekSensor(task_id='weekday_sensor_check_true',
                          week_day=week_day,
                          use_task_execution_day=True,
                          dag=self.dag)
     op.run(start_date=WEEKDAY_DATE,
            end_date=WEEKDAY_DATE,
            ignore_ti_state=True)
     self.assertEqual(op.week_day, week_day)
Пример #4
0
 def test_weekday_sensor_with_string_set_2_items(self):
     week_day = {'Thursday', 'Friday'}
     op = DayOfWeekSensor(task_id='weekday_sensor_check_true',
                          week_day=week_day,
                          use_task_execution_day=True,
                          dag=self.dag)
     op.run(start_date=WEEKDAY_DATE,
            end_date=WEEKDAY_DATE,
            ignore_ti_state=True)
     self.assertEqual(op.week_day, week_day)
Пример #5
0
 def test_weekday_sensor_false(self):
     op = DayOfWeekSensor(
         task_id='weekday_sensor_check_false',
         poke_interval=1,
         timeout=2,
         week_day='Tuesday',
         use_task_execution_day=True,
         dag=self.dag)
     with self.assertRaises(AirflowSensorTimeout):
         op.run(start_date=WEEKDAY_DATE, end_date=WEEKDAY_DATE, ignore_ti_state=True)
Пример #6
0
 def test_invalid_weekday_number(self):
     invalid_week_day = 'Thsday'
     with self.assertRaisesRegex(
             AttributeError,
             'Invalid Week Day passed: "{}"'.format(invalid_week_day)):
         DayOfWeekSensor(task_id='weekday_sensor_invalid_weekday_num',
                         week_day=invalid_week_day,
                         use_task_execution_day=True,
                         dag=self.dag)
Пример #7
0
 def test_weekday_sensor_with_invalid_type(self):
     invalid_week_day = ['Thsday']
     with self.assertRaisesRegex(
             TypeError, 'Unsupported Type for week_day parameter:'
             ' {}. It should be one of str, set or '
             'Weekday enum type'.format(type(invalid_week_day))):
         DayOfWeekSensor(task_id='weekday_sensor_check_true',
                         week_day=invalid_week_day,
                         use_task_execution_day=True,
                         dag=self.dag)