def test_interval_None(self): """Test generator with interval=None""" gen = heartbeat_generator(None, out=self.stdout, time=self.timer) gen.next() self.assertFalse(self.stdout.buflist) self.timer.advance(5) gen.next() self.assertFalse(self.stdout.buflist) self.timer.advance(5)
def test_send_heartbeat_on_interval(self): """Test that we actually send the heartbeat.""" gen = heartbeat_generator(2, out=self.stdout, time=self.timer) gen.next() self.assertFalse(self.stdout.buflist) self.timer.advance(2) gen.next() output = self.stdout.buflist self.assertTrue('<!--XSUPERVISOR:BEGIN-->' in output) self.assertTrue('<!--XSUPERVISOR:END-->' in output)
def test_not_send_heartbeat(self): """Test that we don't send the heartbeat.""" gen = heartbeat_generator(2, out=self.stdout, time=self.timer) gen.next() self.assertFalse(self.stdout.buflist) self.timer.advance(0.5) gen.next() self.assertFalse(self.stdout.buflist) self.timer.advance(0.5) gen.next() self.assertFalse(self.stdout.buflist)