Exemplo n.º 1
0
 def test_cron_clock_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")
     c = clocks.CronClock("0 * * * *", dt)
     if serialize:
         c = ClockSchema().load(ClockSchema().dump(c))
     next_4 = islice(c.events(after=dt), 4)
     # 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]
Exemplo n.º 2
0
 def test_cron_clock_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")
     c = clocks.CronClock("0 * * * *", dt)
     if serialize:
         c = ClockSchema().load(ClockSchema().dump(c))
     next_4 = islice(c.events(after=dt), 4)
     # 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]
Exemplo n.º 3
0
    def test_cron_clock_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")
        c = clocks.CronClock("0 9 * * *", dt)
        if serialize:
            c = ClockSchema().load(ClockSchema().dump(c))
        next_4 = islice(c.events(after=dt), 4)
        # 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]
Exemplo n.º 4
0
    def test_interval_clock_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")
        c = clocks.IntervalClock(timedelta(days=1), start_date=dt)
        if serialize:
            c = ClockSchema().load(ClockSchema().dump(c))
        next_4 = islice(c.events(after=dt), 4)
        # 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]
Exemplo n.º 5
0
 def test_interval_clock_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")
     c = clocks.IntervalClock(timedelta(hours=1), start_date=dt)
     if serialize:
         c = ClockSchema().load(ClockSchema().dump(c))
     next_4 = islice(c.events(after=dt), 4)
     # repeat the 1am run in local time
     assert [t.start_time.in_tz("America/New_York").hour for t in next_4] == [
         0,
         1,
         1,
         2,
     ]
     # runs every hour UTC
     assert [t.start_time.in_tz("UTC").hour for t in next_4] == [4, 5, 6, 7]
Exemplo n.º 6
0
 def test_interval_clock_hourly_daylight_savings_time_forward_with_UTC(
     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")
     c = clocks.IntervalClock(timedelta(hours=1), start_date=dt.in_tz("UTC"))
     if serialize:
         c = ClockSchema().load(ClockSchema().dump(c))
     next_4 = islice(c.events(after=dt), 4)
     # skip 2am
     assert [t.start_time.in_tz("America/New_York").hour for t in next_4] == [
         0,
         1,
         3,
         4,
     ]
     # constant hourly schedule in utc time
     assert [t.start_time.in_tz("UTC").hour for t in next_4] == [5, 6, 7, 8]