@@ -291,6 +291,35 @@ def test_one_off_task(self):
291291 assert not isdue
292292 assert delay == NEVER_CHECK_TIMEOUT
293293
294+ def test_task_with_expires (self ):
295+ interval = 10
296+ right_now = self .app .now ()
297+ one_second_later = right_now + timedelta (seconds = 1 )
298+ m = self .create_model_interval (schedule (timedelta (seconds = interval )),
299+ start_time = right_now ,
300+ expires = one_second_later )
301+ e = self .Entry (m , app = self .app )
302+ isdue , delay = e .is_due ()
303+ assert isdue
304+ assert delay == interval
305+
306+ m2 = self .create_model_interval (schedule (timedelta (seconds = interval )),
307+ start_time = right_now ,
308+ expires = right_now )
309+ e2 = self .Entry (m2 , app = self .app )
310+ isdue , delay = e2 .is_due ()
311+ assert not isdue
312+ assert delay == NEVER_CHECK_TIMEOUT
313+
314+ one_second_ago = right_now - timedelta (seconds = 1 )
315+ m2 = self .create_model_interval (schedule (timedelta (seconds = interval )),
316+ start_time = right_now ,
317+ expires = one_second_ago )
318+ e2 = self .Entry (m2 , app = self .app )
319+ isdue , delay = e2 .is_due ()
320+ assert not isdue
321+ assert delay == NEVER_CHECK_TIMEOUT
322+
294323
295324@pytest .mark .django_db
296325class test_DatabaseSchedulerFromAppConf (SchedulerCase ):
0 commit comments