'Makes sure we can add a chunk and modify it.'

def testAddChunk(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()
    chunk_number = 0
    blob_contents = ('A' * fd.chunksize)
    blob_hash = self.AddBlobToBlobStore(blob_contents).decode('hex')
    fd.AddBlob(blob_hash=blob_hash, length=len(blob_contents), chunk_number=chunk_number)
    fd.Flush()
    self.assertEqual(fd.size, len(blob_contents))
    self.assertChunkEqual(fd, chunk_number, blob_contents)
    blob_contents = ('B' * fd.chunksize)
    blob_hash = self.AddBlobToBlobStore(blob_contents).decode('hex')
    fd.AddBlob(blob_hash, len(blob_contents), chunk_number=chunk_number)
    self.assertEqual(fd.size, len(blob_contents))
    self.assertChunkEqual(fd, chunk_number, blob_contents)
