def test_chunker_no_litter(): """ Test: Write and immediate remove should not leave any object behind """ cas = CAS(ioctx_cas) chunker = Chunker(cas, ioctx_index) data_in = StringIO(random_bytes(chunker.chunk_size*4)) obj_name = random_id() chunker.write_full(obj_name, data_in) chunker.remove_all_versions(obj_name) cas_objs = [x.key for x in ioctx_cas.list_objects()] index_objs = [x.key for x in ioctx_index.list_objects()] print "CAS objects left:", cas_objs print "Index objects left:", index_objs eq(len(cas_objs), 0) eq(len(index_objs), 0)
def test_chunker_no_litter(): """ Test: Write and immediate remove should not leave any object behind """ cas = CAS(ioctx_cas) chunker = Chunker(cas, ioctx_index) data_in = StringIO(random_bytes(chunker.chunk_size * 4)) obj_name = random_id() chunker.write_full(obj_name, data_in) chunker.remove_all_versions(obj_name) cas_objs = [x.key for x in ioctx_cas.list_objects()] index_objs = [x.key for x in ioctx_index.list_objects()] print "CAS objects left:", cas_objs print "Index objects left:", index_objs eq(len(cas_objs), 0) eq(len(index_objs), 0)
def test_chunker_remove(): """ Test: remove actually removes - `remove_version(write_full)`: No versions, but index object - `write_full, write_full, remove_all_versions`: Index object gone """ cas = CAS(ioctx_cas) chunker = Chunker(cas, ioctx_index) data_in = random_bytes(42) obj_name = random_id() version = chunker.write_full(obj_name, StringIO(data_in)) chunker.remove_version(obj_name, version) eq(chunker.head_version(obj_name), None) chunker.write_full(obj_name, StringIO(data_in)) chunker.write_full(obj_name, StringIO(data_in)) chunker.remove_all_versions(obj_name) assert_raises(ObjectNotFound, chunker.head_version, obj_name)