'Test that notifications are not rescheduled forever.'

def testNotificationReschedulingTTL(self):

    with test_lib.FakeTime(10000):
        worker_obj = worker.GRRWorker(token=self.token)
        flow_obj = self.FlowSetup('RaisingTestFlow')
        session_id = flow_obj.session_id
        flow_obj.Close()
        manager = queue_manager.QueueManager(token=self.token)
        notification = rdf_flows.GrrNotification(session_id=session_id, last_status=1)
        with data_store.DB.GetMutationPool(token=self.token) as pool:
            manager.NotifyQueue(notification, mutation_pool=pool)
        notifications = manager.GetNotifications(queues.FLOWS)
        notifications = [n for n in notifications if (n.session_id == session_id)]
        self.assertEqual(len(notifications), 1)
    delay = flow_runner.FlowRunner.notification_retry_interval
    ttl = notification.ttl
    for i in xrange((ttl - 1)):
        with test_lib.FakeTime(((10000 + 100) + (delay * (i + 1)))):
            worker_obj.RunOnce()
            worker_obj.thread_pool.Join()
            notifications = manager.GetNotifications(queues.FLOWS)
            notifications = [n for n in notifications if (n.session_id == session_id)]
            self.assertEqual(len(notifications), 1)
    with test_lib.FakeTime(((10000 + 100) + (delay * ttl))):
        worker_obj.RunOnce()
        worker_obj.thread_pool.Join()
        notifications = manager.GetNotifications(queues.FLOWS)
        self.assertEqual(len(notifications), 0)
