예제 #1
0
 def test_get_next_fire_time(self, run_date, alter_tz, previous, now,
                             expected, timezone, freeze_time):
     trigger = DateTrigger(run_date, alter_tz or timezone)
     previous = timezone.localize(previous) if previous else None
     now = timezone.localize(now)
     expected = timezone.localize(expected) if expected else None
     assert trigger.get_next_fire_time(previous, now) == expected
예제 #2
0
 def test_get_next_fire_time(self, run_date, alter_tz, previous, now, expected, timezone,
                             freeze_time):
     trigger = DateTrigger(run_date, alter_tz or timezone)
     previous = timezone.localize(previous) if previous else None
     now = timezone.localize(now)
     expected = timezone.localize(expected) if expected else None
     assert trigger.get_next_fire_time(previous, now) == expected
예제 #3
0
    def test_dst_change(self, is_dst):
        """
        Making sure that DateTrigger works during the ambiguous "fall-back" DST period.
        Note that you should explicitly compare datetimes as strings to avoid the internal datetime comparison which
        would test for equality in the UTC timezone.
        """

        eastern = pytz.timezone("US/Eastern")
        run_date = eastern.localize(datetime(2013, 11, 3, 1, 5), is_dst=is_dst)

        fire_date = eastern.normalize(run_date + timedelta(minutes=55))
        trigger = DateTrigger(run_date=fire_date, timezone=eastern)
        assert str(trigger.get_next_fire_time(None, fire_date)) == str(fire_date)
예제 #4
0
    def test_dst_change(self, is_dst):
        """
        Test that DateTrigger works during the ambiguous "fall-back" DST period.

        Note that you should explicitly compare datetimes as strings to avoid the internal datetime
        comparison which would test for equality in the UTC timezone.

        """
        eastern = pytz.timezone('US/Eastern')
        run_date = eastern.localize(datetime(2013, 10, 3, 1, 5), is_dst=is_dst)

        fire_date = eastern.normalize(run_date + timedelta(minutes=55))
        trigger = DateTrigger(run_date=fire_date, timezone=eastern)
        assert str(trigger.get_next_fire_time(None, fire_date)) == str(fire_date)