bolkedebruin commented on a change in pull request #4117: [AIRFLOW-3277] 
Correctly observe DST transitions for cron
URL: https://github.com/apache/incubator-airflow/pull/4117#discussion_r229624252
 
 

 ##########
 File path: tests/models.py
 ##########
 @@ -580,6 +580,29 @@ def test_cycle(self):
         with self.assertRaises(AirflowDagCycleException):
             dag.test_cycle()
 
+    def test_following_previous_schedule(self):
+        """
+        Make sure DST transitions are properly observed
+        """
+        local_tz = pendulum.timezone('Europe/Zurich')
+        start = datetime(2018, 10, 28, 3, 00, tzinfo=local_tz)
+        utc = timezone.convert_to_utc(start)
+
+        dag = DAG('tz_dag', start_date=start, schedule_interval="'*/5 * * * 
*'")
+        next = dag.following_schedule(utc)
+        next_local = local_tz.convert(next)
+
+        # should give 2018, 10, 28, 3, 5
+        self.assertEqual(next_local.hour, 3)
+        self.assertEqual(next_local.minute, 5)
+
+        prev = dag.previous_schedule(utc)
+        prev_local = local_tz.convert(prev)
+
+        # should give 2018, 10, 28, 1, 55
+        self.assertEqual(prev_local.hour, 1)
+        self.assertEqual(prev_local.minute, 55)
 
 Review comment:
   Ah yes, this is why I did the initial conversion to local time with cron. 
Ie. the schedule is tied to local time, so if we use UTC and apply the schedule 
then we will make mistakes.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to