'Check that requests get retransmitted but only if there is no status.'

def testHandleClientMessageRetransmission(self):

    client_id = self.SetupClients(1)[0]
    base_time = 1000
    msgs_recvd = []
    default_ttl = rdf_flows.GrrMessage().task_ttl
    with test_lib.FakeTime(base_time):
        flow.GRRFlow.StartFlow(client_id=client_id, flow_name=flow_test_lib.SendingFlow.__name__, message_count=1, token=self.token)
    for i in range(default_ttl):
        with test_lib.FakeTime((base_time + (i * (self.message_expiry_time + 1)))):
            tasks = self.server.DrainTaskSchedulerQueueForClient(client_id, 100000)
            msgs_recvd.append(tasks)
    self.assertEqual(map(bool, msgs_recvd), (([True] * (rdf_flows.GrrMessage().task_ttl - 1)) + [False]))
    if (default_ttl <= 3):
        self.fail('TTL    too    low    for    this    test.')
    msgs_recvd = []
    with test_lib.FakeTime(base_time):
        flow_id = flow.GRRFlow.StartFlow(client_id=client_id, flow_name=flow_test_lib.SendingFlow.__name__, message_count=1, token=self.token)
    for i in range(default_ttl):
        if (i == 2):
            self._ScheduleResponseAndStatus(client_id, flow_id)
        with test_lib.FakeTime((base_time + (i * (self.message_expiry_time + 1)))):
            tasks = self.server.DrainTaskSchedulerQueueForClient(client_id, 100000)
            msgs_recvd.append(tasks)
            if (not tasks):
                new_tasks = queue_manager.QueueManager(token=self.token).Query(queue=rdf_client.ClientURN(client_id).Queue(), limit=1000)
                self.assertEqual(len(new_tasks), 0)
    self.assertEqual(map(bool, msgs_recvd), (([True] * 2) + ([False] * (rdf_flows.GrrMessage().task_ttl - 2))))
