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]
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]
async def test_interval_clock_units(self, run_query, flow_group_id): await run_query( query=self.mutation, variables=dict(input=dict( flow_group_id=flow_group_id, interval_clocks=[{ "interval": 60 }], )), ) flow_group = await models.FlowGroup.where(id=flow_group_id ).first({"schedule"}) deserialized_schedule = ScheduleSchema().load(flow_group.schedule) next_two = deserialized_schedule.next(n=2) assert next_two[0].add(minutes=1) == next_two[1]
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]
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]