def test_chunker_partial_read_past_size(): """ Test: partial reads past *file* size """ cas = CAS(ioctx_cas) chunker = Chunker(cas, ioctx_index) data_in = StringIO("\x00" * chunker.chunk_size) obj_name = random_id() version = chunker.write_full(obj_name, data_in) buf = chunker.read(obj_name, chunker.chunk_size, chunker.chunk_size, version) eq_buffer(buf, "")
def test_chunker_partial_read(): """ Test: partial reads using chunker.read with different input and weird extents """ cas = CAS(ioctx_cas) chunker = Chunker(cas, ioctx_index) data_in = StringIO("\x00" * chunker.chunk_size + "\xFF" * chunker.chunk_size) obj_name = random_id() version = chunker.write_full(obj_name, data_in) middle = chunker.chunk_size / 2 buf = chunker.read(obj_name, chunker.chunk_size, middle, version) eq(len(buf), chunker.chunk_size) eq_buffer("\x00" * (chunker.chunk_size/2) + "\xFF" * (chunker.chunk_size/2), buf)
def test_chunker_partial_read(): """ Test: partial reads using chunker.read with different input and weird extents """ cas = CAS(ioctx_cas) chunker = Chunker(cas, ioctx_index) data_in = StringIO("\x00" * chunker.chunk_size + "\xFF" * chunker.chunk_size) obj_name = random_id() version = chunker.write_full(obj_name, data_in) middle = chunker.chunk_size / 2 buf = chunker.read(obj_name, chunker.chunk_size, middle, version) eq(len(buf), chunker.chunk_size) eq_buffer( "\x00" * (chunker.chunk_size / 2) + "\xFF" * (chunker.chunk_size / 2), buf)