'Test MultiGetFile downloading many files at once.'

def testMultiGetFileMultiFiles(self):

    client_mock = action_mocks.MultiGetFileClientMock()
    pathspecs = []
    for i in xrange(30):
        path = os.path.join(self.temp_dir, ('test_%s.txt' % i))
        with open(path, 'wb') as fd:
            fd.write('Hello')
        pathspecs.append(rdf_paths.PathSpec(pathtype=rdf_paths.PathSpec.PathType.OS, path=path))
    args = transfer.MultiGetFileArgs(pathspecs=pathspecs, maximum_pending_files=10)
    for session_id in flow_test_lib.TestFlowHelper(transfer.MultiGetFile.__name__, client_mock, token=self.token, client_id=self.client_id, args=args):
        flow_obj = aff4.FACTORY.Open(session_id, mode='r', token=self.token)
        flow_state = flow_obj.state
        self.assertEqual(len(flow_state.indexed_pathspecs), 30)
        self.assertLessEqual(len(flow_state.pending_files), 10)
        self.assertLessEqual(len(flow_state.pending_hashes), 10)
    for flow_pathspec in flow_state.indexed_pathspecs:
        self.assertIsNone(flow_pathspec)
    for flow_request_data in flow_state.request_data_list:
        self.assertIsNone(flow_request_data)
    for pathspec in pathspecs:
        urn = pathspec.AFF4Path(self.client_id)
        fd = aff4.FACTORY.Open(urn, token=self.token)
        self.assertEqual('Hello', fd.Read(100000))
