diff options
author | Paul "LeoNerd" Evans <paul@matrix.org> | 2014-12-10 19:24:12 +0000 |
---|---|---|
committer | Paul "LeoNerd" Evans <paul@matrix.org> | 2014-12-10 19:24:12 +0000 |
commit | 38da9884e70e8e44bde14c67a7a8a9d49a8b87ac (patch) | |
tree | 2de9674ac2f460987d2c59cd653586ed28fdd767 /tests/test_test_utils.py | |
parent | Trivial test of MockClock() (diff) | |
download | synapse-38da9884e70e8e44bde14c67a7a8a9d49a8b87ac.tar.xz |
Implement .call_later() in MockClock
Diffstat (limited to 'tests/test_test_utils.py')
-rw-r--r-- | tests/test_test_utils.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/test_test_utils.py b/tests/test_test_utils.py index 11c5db3cd9..dcf946fc1a 100644 --- a/tests/test_test_utils.py +++ b/tests/test_test_utils.py @@ -28,3 +28,25 @@ class MockClockTestCase(unittest.TestCase): self.clock.advance_time(20) self.assertEquals(20, self.clock.time() - start_time) + + def test_later(self): + invoked = [0, 0] + + def _cb0(): + invoked[0] = 1 + self.clock.call_later(10, _cb0) + + def _cb1(): + invoked[1] = 1 + self.clock.call_later(20, _cb1) + + self.assertFalse(invoked[0]) + + self.clock.advance_time(15) + + self.assertTrue(invoked[0]) + self.assertFalse(invoked[1]) + + self.clock.advance_time(5) + + self.assertTrue(invoked[1]) |