dstandish commented on code in PR #30083:
URL: https://github.com/apache/airflow/pull/30083#discussion_r1393372659
##########
tests/timetables/test_interval_timetable.py:
##########
@@ -253,3 +253,83 @@ def
test_cron_next_dagrun_info_alignment(last_data_interval: DataInterval, expec
restriction=TimeRestriction(None, None, True),
)
assert info == expected_info
+
+
+def test_cron_interval_dst_next_entering():
+ """
+ This test is composed of several tests targeting an interval
+ timetable crossing a timezone change boundary, e.g. DST
+ """
+ # Interval cron
+ cron_interval = CronDataIntervalTimetable(
+ "0 9-16 * * 1-5", timezone=pendulum.timezone("America/New_York")
+ )
+ # Fixed cron
+ cron_fixed = CronDataIntervalTimetable("0 9 * * 1-5",
timezone=pendulum.timezone("America/New_York"))
+
+ # last run friday before DST
+ last_run = pendulum.datetime(2023, 3, 10, 21, 0)
+
+ # last run: 2023-03-10 21:00:00+00:00
+ # expected next run: 2023-03-13 13:00:00+00:00
+ # these should match:
+ assert cron_interval._get_next(last_run).timestamp() ==
cron_fixed._get_next(last_run).timestamp()
+
+
+def test_cron_interval_dst_prev_entering():
+ """
+ This test is composed of several tests targeting an interval
+ timetable crossing a timezone change boundary, e.g. DST
+ """
+ # Interval cron
+ cron_interval = CronDataIntervalTimetable(
+ "0 9-16 * * 1-5", timezone=pendulum.timezone("America/New_York")
+ )
+ # Fixed cron
+ cron_fixed = CronDataIntervalTimetable("0 16 * * 1-5",
timezone=pendulum.timezone("America/New_York"))
+
+ last_run = pendulum.datetime(2023, 3, 10, 13, 0)
+ # last run: 2023-03-13 13:00:00+00:00
+ # expected prev run: 2023-03-10 21:00:00+00:00
+ # these should match:
+ assert cron_interval._get_prev(last_run).timestamp() ==
cron_fixed._get_prev(last_run).timestamp()
+
+
+def test_cron_interval_dst_next_leaving():
Review Comment:
we should probably verify the DST transition behavior with the
`CronTriggerTimetable` class also. perhaps parameterizing would be an easy way
to do that.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]