def test_HashedAccessor_get_path_for_file(content, path, hashtype, lens): from oniontree.accessors.hashed import HashedAccessor from pathlib import PosixPath import hashlib, io hasacc = HashedAccessor(getattr(hashlib, hashtype), lens) assert hasacc.get_path_for_file(io.BytesIO(content)) == PosixPath(path)
def test_HashedAccessor_get_id_from_path(id_, path): from oniontree.accessors.hashed import HashedAccessor from pathlib import PosixPath assert HashedAccessor.get_id_from_path(PosixPath(path)) == id_
def test_HashedAccessor_get_path_from_id(id_, path, lens): from oniontree.accessors.hashed import HashedAccessor from pathlib import PosixPath hasacc = HashedAccessor(None, [4, 2, 8]) assert hasacc.get_path_from_id(id_) == PosixPath(path)