'Read a chunk, and test that the next few are in cache.'

def testReadAhead(self):

    urn = aff4.ROOT_URN.Add('temp_sparse_image.dd')
    fd = aff4.FACTORY.Create(urn, aff4_type=aff4_standard.AFF4SparseImage, token=self.token, mode='rw')
    fd.Set(fd.Schema._CHUNKSIZE, rdfvalue.RDFInteger(1024))
    fd.chunksize = 1024
    fd.Flush()
    start_chunk = 1000
    blob_hashes = []
    blobs = []
    num_chunks = 5
    for chunk in xrange(start_chunk, (start_chunk + num_chunks)):
        blob_contents = (str((chunk % 10)) * fd.chunksize)
        blobs.append(blob_contents)
        blob_hash = self.AddBlobToBlobStore(blob_contents).decode('hex')
        fd.AddBlob(blob_hash=blob_hash, length=len(blob_contents), chunk_number=chunk)
        blob_hashes.append(blob_hash)
    self.assertEqual(fd.size, (fd.chunksize * num_chunks))
    fd.Seek((start_chunk * fd.chunksize))
    fd.Read(fd.chunksize)
    self.assertEqual(len(fd.chunk_cache._hash), num_chunks)
    fd.Flush()
    self.assertFalse(fd.chunk_cache._hash.keys())
    fd.Seek((start_chunk * fd.chunksize))
    self.assertEqual(fd.Read((fd.chunksize * num_chunks)), ''.join(blobs))
