def testReceiveMessagesWithStatus(self):
    """Receiving a sequence of messages with a status."""
    flow_obj = self.FlowSetup("FlowOrderTest")

    session_id = flow_obj.session_id
    messages = [rdf_flows.GrrMessage(request_id=1,
                                     response_id=i,
                                     session_id=session_id,
                                     payload=rdfvalue.RDFInteger(i),
                                     task_id=15)
                for i in range(1, 10)]

    # Now add the status message
    status = rdf_flows.GrrStatus(status=rdf_flows.GrrStatus.ReturnedStatus.OK)
    messages.append(rdf_flows.GrrMessage(
        request_id=1, response_id=len(messages) + 1, task_id=15,
        session_id=messages[0].session_id, payload=status,
        type=rdf_flows.GrrMessage.Type.STATUS))

    self.server.ReceiveMessages(self.client_id, messages)

    # Make sure the task is still on the client queue
    manager = queue_manager.QueueManager(token=self.token)
    tasks_on_client_queue = manager.Query(self.client_id, 100)
    self.assertEqual(len(tasks_on_client_queue), 1)

    # Check that messages were stored correctly
    for message in messages:
      stored_message, _ = data_store.DB.Resolve(
          session_id.Add("state/request:00000001"),
          manager.FLOW_RESPONSE_TEMPLATE % (1, message.response_id),
          token=self.token)

      stored_message = rdf_flows.GrrMessage(stored_message)
      self.assertRDFValuesEqual(stored_message, message)
dataset/ETHPy150Open google/grr/grr/lib/front_end_test.py/GRRFEServerTest.testReceiveMessagesWithStatus/original