예제 #1
0
 def test_cron_schedule_hourly_daylight_savings_time_forward(
         self, serialize):
     """
     On 3/11/2018, at 2am, America/New_York switched clocks forward an hour.
     """
     dt = pendulum.datetime(2018, 3, 10, 23, tz="America/New_York")
     s = schedules.CronSchedule("0 * * * *", dt)
     if serialize:
         s = ScheduleSchema().load(s.serialize())
     next_4 = s.next(4, after=dt)
     # skip 2am
     assert [t.in_tz("America/New_York").hour
             for t in next_4] == [0, 1, 3, 4]
     # constant hourly schedule in utc time
     assert [t.in_tz("UTC").hour for t in next_4] == [5, 6, 7, 8]
예제 #2
0
 def test_cron_schedule_hourly_daylight_savings_time_backward(
         self, serialize):
     """
     11/4/2018, at 2am, America/New_York switched clocks back an hour.
     """
     dt = pendulum.datetime(2018, 11, 3, 23, tz="America/New_York")
     s = schedules.CronSchedule("0 * * * *", dt)
     if serialize:
         s = ScheduleSchema().load(s.serialize())
     next_4 = s.next(4, after=dt)
     # repeat the 1am run in local time
     assert [t.in_tz("America/New_York").hour
             for t in next_4] == [0, 1, 2, 3]
     # runs every hour UTC
     assert [t.in_tz("UTC").hour for t in next_4] == [4, 6, 7, 8]
예제 #3
0
    def test_cron_schedule_daily_start_daylight_savings_time_backward(
            self, serialize):
        """
        On 11/4/2018, at 2am, America/New_York switched clocks back an hour.

        Confirm that a schedule for 9am America/New_York stays 9am through the switch.
        """
        dt = pendulum.datetime(2018, 11, 1, 9, tz="America/New_York")
        s = schedules.CronSchedule("0 9 * * *", dt)
        if serialize:
            s = ScheduleSchema().load(s.serialize())
        next_4 = s.next(4, after=dt)
        # constant 9am start
        assert [t.in_tz("America/New_York").hour
                for t in next_4] == [9, 9, 9, 9]
        assert [t.in_tz("UTC").hour for t in next_4] == [13, 13, 14, 14]
예제 #4
0
    def test_interval_schedule_daily_start_daylight_savings_time_forward(
            self, serialize):
        """
        On 3/11/2018, at 2am, America/New_York switched clocks forward an hour.

        Confirm that a schedule for 9am America/New_York stays 9am through the switch.
        """
        dt = pendulum.datetime(2018, 3, 8, 9, tz="America/New_York")
        s = schedules.IntervalSchedule(dt, timedelta(days=1))
        if serialize:
            s = ScheduleSchema().load(s.serialize())
        next_4 = s.next(4, after=dt)
        # constant 9am start
        assert [t.in_tz("America/New_York").hour
                for t in next_4] == [9, 9, 9, 9]
        # utc time shifts
        assert [t.in_tz("UTC").hour for t in next_4] == [14, 14, 13, 13]