def check_file_storage(self): name = mktemp() b = FileStorage(name) assert b.new_oid() == int8_to_str(0) assert b.new_oid() == int8_to_str(1) assert b.new_oid() == int8_to_str(2) raises(KeyError, b.load, int8_to_str(0)) record = pack_record(int8_to_str(0), as_bytes('ok'), as_bytes('')) b.begin() b.store(int8_to_str(0), record) b.end() b.sync() b.begin() b.store(int8_to_str(1), pack_record( int8_to_str(1), as_bytes('no'), as_bytes(''))) b.end() assert len(list(b.gen_oid_record(start_oid=int8_to_str(0)))) == 1 assert len(list(b.gen_oid_record())) == 2 b.pack() b.close() unlink(name + '.prepack') raises(ValueError, b.pack) # storage closed unlink(name + '.pack') raises(ValueError, b.load, int8_to_str(0)) # storage closed unlink(name)
def check_file_storage(self): name = mktemp() b = FileStorage(name) assert b.new_oid() == int8_to_str(0) assert b.new_oid() == int8_to_str(1) assert b.new_oid() == int8_to_str(2) raises(KeyError, b.load, int8_to_str(0)) record = pack_record(int8_to_str(0), as_bytes('ok'), as_bytes('')) b.begin() b.store(int8_to_str(0), record) b.end() b.sync() b.begin() b.store(int8_to_str(1), pack_record(int8_to_str(1), as_bytes('no'), as_bytes(''))) b.end() assert len(list(b.gen_oid_record(start_oid=int8_to_str(0)))) == 1 assert len(list(b.gen_oid_record())) == 2 b.pack() b.close() unlink(name + '.prepack') raises(ValueError, b.pack) # storage closed unlink(name + '.pack') raises(ValueError, b.load, int8_to_str(0)) # storage closed unlink(name)