|
@@ -1,6 +1,7 @@
|
|
|
from __future__ import absolute_import, unicode_literals
|
|
|
|
|
|
import time
|
|
|
+import pytz
|
|
|
from contextlib import contextmanager
|
|
|
from datetime import datetime, timedelta
|
|
|
from pickle import dumps, loads
|
|
@@ -439,6 +440,40 @@ class test_crontab_remaining_estimate:
|
|
|
)
|
|
|
assert next == datetime(2016, 2, 29, 14, 30)
|
|
|
|
|
|
+ def test_day_after_dst_end(self):
|
|
|
+
|
|
|
+ tzname = "Europe/Paris"
|
|
|
+ self.app.timezone = tzname
|
|
|
+ tz = pytz.timezone(tzname)
|
|
|
+ crontab = self.crontab(minute=0, hour=9)
|
|
|
+
|
|
|
+
|
|
|
+ last_run_at = tz.localize(datetime(2017, 10, 28, 9, 0))
|
|
|
+
|
|
|
+ now = tz.localize(datetime(2017, 10, 29, 7, 0))
|
|
|
+ crontab.nowfun = lambda: now
|
|
|
+ next = now + crontab.remaining_estimate(last_run_at)
|
|
|
+
|
|
|
+ assert next.utcoffset().seconds == 3600
|
|
|
+ assert next == tz.localize(datetime(2017, 10, 29, 9, 0))
|
|
|
+
|
|
|
+ def test_day_after_dst_start(self):
|
|
|
+
|
|
|
+ tzname = "Europe/Paris"
|
|
|
+ self.app.timezone = tzname
|
|
|
+ tz = pytz.timezone(tzname)
|
|
|
+ crontab = self.crontab(minute=0, hour=9)
|
|
|
+
|
|
|
+
|
|
|
+ last_run_at = tz.localize(datetime(2017, 3, 25, 9, 0))
|
|
|
+
|
|
|
+ now = tz.localize(datetime(2017, 3, 26, 7, 0))
|
|
|
+ crontab.nowfun = lambda: now
|
|
|
+ next = now + crontab.remaining_estimate(last_run_at)
|
|
|
+
|
|
|
+ assert next.utcoffset().seconds == 7200
|
|
|
+ assert next == tz.localize(datetime(2017, 3, 26, 9, 0))
|
|
|
+
|
|
|
|
|
|
class test_crontab_is_due:
|
|
|
|