Exemplo n.º 1
0
 def test_delay_4(self):
     """
     Base case: can emit second time after *more* than enough time passed.
     """
     delay = 10
     emitter = MarbleEmitter(self.__mock_prototype, delay)
     emitter.register_time_passed(delay + 10)
     self.assertTrue(emitter.can_emit())
Exemplo n.º 2
0
 def test_delay_2(self):
     """
     Base case: cannot emit right after previous emit, when delay > 0.
     """
     delay = 10
     emitter = MarbleEmitter(self.__mock_prototype, delay)
     emitter.register_time_passed(delay)
     emitter.emit()
     self.assertFalse(emitter.can_emit())
Exemplo n.º 3
0
 def test_emit_1(self):
     """
     Corner case: throw error when trying to emit 
     too early after previous emit.
     """
     delay = 10
     emitter = MarbleEmitter(self.__mock_prototype, delay)
     emitter.register_time_passed(delay)
     emitter.emit()
     emitter.register_time_passed(delay / 2)
     self.assertRaises(RuntimeError, emitter.emit)