Exemplo n.º 1
0
 def test_len(self):
     a = EventScheduler(sleep_func=self.mock_sleep)
     self.assertTrue(len(a) == 0)
     a.add_event(5, lambda: None)
     self.assertTrue(len(a) == 1)
     a.run_next_set()
     self.assertTrue(len(a) == 0)
Exemplo n.º 2
0
 def test_bool(self):
     a = EventScheduler(sleep_func=self.mock_sleep)
     self.assertFalse(a)
     a.add_event(5, lambda: None)
     self.assertTrue(a)
     a.run_next_set()
     self.assertFalse(a)
Exemplo n.º 3
0
 def test_run_set(self):
     # Insertion order should be preserved (STABLE SORT SON)
     a = EventScheduler(sleep_func=self.mock_sleep)
     self.assertTrue(None == a.run_next())
     a.add_event(6, self.mock_callable)
     a.add_event(5, self.mock_callable)
     a.add_event(5, self.mock_callable, [1, 2, 3])
     ret = a.run_next_set()
     self.assertTrue(len(ret) == 2)
     self.assertTrue(len(self.last_args) == 3)
     ret = a.run_next_set()
     self.assertTrue(len(ret) == 1)
     self.assertTrue(len(self.last_args) == 0)
Exemplo n.º 4
0
 def test_add_event(self):
     a = EventScheduler(sleep_func=self.mock_sleep)
     a.add_event(5, self.mock_callable)
     a.add_event(6, self.mock_callable, [1, 2, 3])
     a.add_event(1, self.mock_callable, [1, 2, 3, 4])
     a.run_next_set()
     self.assertTrue(len(self.last_args) == 4)
     a.run_next_set()
     self.assertTrue(len(self.last_args) == 0)
     a.run_next_set()
     self.assertTrue(len(self.last_args) == 3)
Exemplo n.º 5
0
 def test_sleep_func(self):
     a = EventScheduler(sleep_func=self.mock_sleep)
     a.add_event(5, lambda: None)
     a.run_next_set()