def schedule(self, delay, callable): self.calls.append((delay, callable)) return schedule.ScheduledCall(delay, callable)
def test_order(self): now = vdsm.common.time.monotonic_time() call_soon = schedule.ScheduledCall(now, self.callback) call_later = schedule.ScheduledCall(now + 1, self.callback) self.assertLess(call_soon, call_later)
def test_execute(self): call = schedule.ScheduledCall(0, self.callback) call._execute() self.assertEqual(1, self.count) self.assertFalse(call.valid())
def test_execute_callback_once(self): call = schedule.ScheduledCall(0, self.callback) call._execute() call._execute() self.assertEqual(1, self.count)
def test_create(self): call = schedule.ScheduledCall(0, self.callback) self.assertEqual(0, self.count) self.assertTrue(call.valid())