def delete(self): if self.empty(): #For delete account. if os.path.ismount(self.datadir): clean_metadata(self.datadir) else: rmdirs(self.datadir) self.dir_exists = False
def test_clean_metadata(self): path = "/tmp/foo/c" expected_d = { 'a': 'y' * 150000 } expected_p = pickle.dumps(expected_d, utils.PICKLE_PROTOCOL) for i in range(0,3): xkey = _xkey(path, "%s%s" % (utils.METADATA_KEY, i or '')) _xattrs[xkey] = expected_p[:utils.MAX_XATTR_SIZE] expected_p = expected_p[utils.MAX_XATTR_SIZE:] assert not expected_p utils.clean_metadata(path) assert _xattr_op_cnt['remove'] == 4, "%r" % _xattr_op_cnt
def test_clean_metadata_err(self): path = "/tmp/foo/c" xkey = _xkey(path, utils.METADATA_KEY) _xattrs[xkey] = pickle.dumps({ 'a': 'y' }, utils.PICKLE_PROTOCOL) _xattr_err[xkey] = errno.EOPNOTSUPP try: utils.clean_metadata(path) except IOError as e: assert e.errno == errno.EOPNOTSUPP assert _xattr_op_cnt['remove'] == 1, "%r" % _xattr_op_cnt else: self.fail("Expected an IOError exception on remove")