

def test_read_all_data(self):
    '\n        Replicate what goes on in the Swift driver with the\n        repeated creation of the ChunkReader object\n        '
    CHUNKSIZE = 100
    checksum = hashlib.md5()
    data_file = tempfile.NamedTemporaryFile()
    data_file.write((b'*' * units.Ki))
    data_file.flush()
    infile = open(data_file.name, 'rb')
    bytes_read = 0
    while True:
        cr = swift.ChunkReader(infile, checksum, CHUNKSIZE)
        chunk = cr.read(CHUNKSIZE)
        if (len(chunk) == 0):
            self.assertEqual(True, cr.is_zero_size)
            break
        bytes_read += len(chunk)
    self.assertEqual(units.Ki, bytes_read)
    self.assertEqual('fb10c6486390bec8414be90a93dfff3b', cr.checksum.hexdigest())
    data_file.close()
    infile.close()

dataset/ETHPy150Open openstack/glance_store/glance_store/tests/unit/test_swift_store.py TestChunkReader.test_read_all_data/original