Ejemplo n.º 1
0
 def test_is_due(self):
     ts = MockTaskSchedule()
     ts._task = MockPeriodicTask()
     ts._task._last_run_at = dt.datetime.utcnow() - dt.timedelta(minutes=5)
     entry = StoreEntry(ts)
     is_due, delay = entry.is_due()
     self.assertTrue(is_due)
     self.assertLess(delay, 60.1)
Ejemplo n.º 2
0
    def test_is_not_due(self):
        ts = MockTaskSchedule()
        ts._task = MockPeriodicTask()
        ts._task._last_run_at = dt.datetime.utcnow() + dt.timedelta(days=1)

        entry = StoreEntry(ts)
        is_due, delay = entry.is_due()
        self.assertFalse(is_due)
        self.assertGreater(delay, (24 * 3600) - 100)
Ejemplo n.º 3
0
 def test_inactive_never_due(self):
     ts = MockTaskSchedule()
     class MockPeriodicTask2(MockPeriodicTask):
         @property
         def is_active(self):
             return False
     ts._task = MockPeriodicTask2()
     ts._task._last_run_at = dt.datetime.utcnow() - dt.timedelta(days=1)
     entry = StoreEntry(ts)
     is_due, delay = entry.is_due()
     self.assertFalse(is_due)
     self.assertEqual(delay, 5.0)